IP[y]: Notebook
Homework1 Last Checkpoint: Jan 19 07:57 (autosaved)
File
Edit
View
Insert
Cell
Kernel
Help
Cell Toolbar:
Finance 4480
Homework 1
Due January 23, 2015
This homework is all about putting to use your knowledge of Python from the different building blocks that you have seen so far.
We will be talking about these problems and I will give lots of hints in class!
1.1.1 Problem 1
This problem is known as the chicken nuggets problem. It goes like this: you walk into Chick Fil-A with an unlimited amount of money (and appetite!). You can purchase nuggets in containers of 6, 9, and 20.
Write a program to tell you the highest number of nuggets that you cannot purchase! Re-read that just in case it went past you the first time! The highest number that you cannot get. For example, you can get 15 nuggets by purchasing and box of 6 and a box of 9 nuggets. You can get 18 by purchasing 2 boxes of 9 nuggets. But with no combination of 6, 9, and 20 can you purchase 17 nuggets. What is the highest number that you cannot get?!
This simple game will give you experience assembling different bits of Python programming to find the solution. It will also employ a very simple numerical method called brute force search.
Please write your solution in the code cell below:
In [5]:
import numpy as np def main(): # your code goes here! print("Nuggets Problem") # remove this line of code for your final solution! number_array = np.array([ False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]) print ("Initializing Array") number = 1 while number < 100: number_array[number] = False number = number + 1 print ("Adding 6's") n6 = 1 number = n6 * 6 while number < 100: number_array[number] = 1 n6 = n6 + 1 number = n6 * 6 print ("Adding 9's") n9 = 1 number = n9 * 9 while number < 100: number_array[number] = 1 n9 = n9 + 1 number = n9 * 9 print ("Adding 20's") n20 = 1 number = n20 * 20 while number < 100: number_array[number] = 1 n20 = n20 + 1 number = n20 * 20 print ("Adding 6, 9, and 20") number = 1 while number < 100: if number_array[number] == 1: number_array[number + 6] = 1 number_array[number + 9] = 1 number_array[number + 20] = 1 number = number + 1 print ("Looking for highest") highest = 0 number = 1 while number < 100: if number_array[number] == 0: highest = number number = number + 1 print "Highest=" print highest if __name__ == "__main__": main()
Initializing Array
Adding 6's
Adding 9's
Adding 20's
Adding 6, 9, and 20
Looking for highest
Highest=
43
Nuggets Problem
Problem 2
In the book Python Programming for the Absolute Beginner, 3rd Edition the author teaches Python through some simple game programming. One of the first games that he shows how to write is the so-called Guess My Number game, which is the children's game of guessing some one's secret number (a number between 1 and 100).
An implementation of the game in Python might look something like this:
In [ ]:
import random def print_header(): print("\tWelcome to 'Guess My Number'!") print("\tI'm thinking of a number between 1 and 100.") print("\tTry to guess it in as few
Gottfried Leibniz, a German philosopher, was born in 1646 and died in 1716. He is renown for his works in philosophy, mathematics, physics and various other intellectual pursuits. His contributions to mathematics included the independent founding of infinitesimal calculus, mathematical notations, works on binary numbers and mechanical calculators. In physics, he was credited for his theories on the relativity of motion, space, and time, as well as studies on kinetic energy, potential energy and the…
requires apodictic reasoning, which is basically reasoning based on the Greek proof, apodeixis. Induction proofs are especially effective when one needs to form a statement that is true for all whole numbers. Proofs by contradiction establishes the truth of a statement by assuming that the statement is false and deducing a contradiction. Reaction As an elementary teacher who has not taught math in over 10 years, the reading was quite difficult to comprehend. The connections were not meaningful to…
others, you sent it to the Library of Alexandria. Meanwhile, many mathematicians includes Euclid, Archimedes, Eratosthenes, Heron were active or have their master piece in Library of Alexandria. It is them who build the foundation of contemporary mathematic. ⅡFamous Mathematician (a) Euclid Euclid was the most distinguished mathematicians. When Ptolemy I, he was a teacher in school of Alexandria. Library of Alexandria includes many of the Euclid authentic originals, including 'The Elements'.…
persuades our challenger (i.e., we hope that our rhetoric is up to the task), but, more importantly, we hope that our evidence really justifies our opinion. It is striking, though, how different branches of knowledge — the humanities, the sciences, mathematics — justify their findings so very differently; they have, one might say, quite incommensurate rules of evidence. Often a shift of emphasis, or framing, of one of these disciplines goes along with, or derives from, a change of these rules, or of the…
Instructor Comments. This week we learn about number systems, mathematical systems and algebraic topics. As you read these sections, please pay close attention to the examples as well as the real world applications that are shown in the book. When working the discussion questions this week there are a few things to keep in mind. Averages involve adding up the total and dividing it by the number of unit we are using to find the average. Averages help us to find unit weights, unit cost, price…
of calculus and was also the first to explore applications of both integration and differentiation in a single work. However, since Leibniz was the first to publish a dissertation on calculus, he was given the total credit for the discovery for a number of years. This later led, of course, to accusations of plagiarism being hurled relentlessly in the direction of Leibniz. There was speculation that Leibniz may have gleaned some of his insights from two of Newton's manuscripts on fluxions, and that…
buildings in Mayan society were made from stone, and the most eminent constructions are ceremonial platforms, palaces, E-groups, pyramids and temples, observatories and ball court. Another marking feature of Mayan architecture was the corbel arch or false arch which not only could help the buildings gain more air but also lighten the weight which was put on the lintel (Maya civilization, n.d.). 2.4. Writing system. The Maya writing system which is based on phonetic symbols and logograms was the only…
begin with an equal sign and all EXCEL descriptive statistical functions have at least one range of cells as its argument. Example: Numerical data is in cells C3:C209. This is the cell range. =average(C3:C209) will compute the average of all the numbers in C3:C209. The cell range in this example is C3:C209. The colon is used to denote the cell range. Univariate descriptive =average( cell range ) =geomean( cell range) =median( cell range ) =stdev( cell range ) =count( cell range ) =quartile( cell…
Proposition by an early 20th century professor Elisha Scott Loomis. The book is a collection of 367 proofs of the Pythagorean Theorem and has been republished by NCTM in 1968. In the Foreword, the author rightly asserts that the number of algebraic proofs is limitless as is also the number of geometric proofs, but that the proposition admits no trigonometric proof. Curiously, nowhere in the book does Loomis mention Euclid's VI.31 even when offering it and the variants as algebraic proofs 1 and 93 or as geometric…
1. Incredulously: not credulous; disinclined or indisposed to believe; skeptical. 2.Affluent:having an abundance of wealth, property, or other materialgoods; prosperous; rich: an affluent person. 3. Catsup: ketchup. 4. Vigor: active strength or force. 5. Trepidation: tremulous fear, alarm, or agitation; perturbation. 6. Superette: a grocery store with some of the self-service features of asupermarket. 7.Indignantly:feeling, characterized by, or expressing strong displeasure atsomething considered unjust…