Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #from http://learnpythonthehardway.org/book/ex24.html
- # narrowed down the code around the tuple problem
- # the original code from the site is written for Python 2.7
- #below is written for python 3.3
- def secret_formula(started):
- jelly_beans= started *500
- jars = jelly_beans / 1000
- crates = jars / 100
- return jelly_beans, jars, crates
- start_point = 10000
- beans, jars, crates = secret_formula(start_point)
- print ("With a starting point of: {}".format(start_point))
- print ("We'd have {} beans, {} jars, and {} crates.".format(beans, jars, crates))
- start_point = (start_point /10)
- print ("We can also do that this way: ")
- print ("Start point",start_point)#testing what interpreter sees
- print ("secret formula", secret_formula)#testing what interpreter sees
- print ("We'd have {} beans, {} jars, and {} crates.".format (secret_formula(start_point)))
- #error text
- """
- With a starting point of: 10000
- We'd have 5000000 beans, 5000.0 jars, and 50.0 crates.
- We can also do that this way:
- Start point 1000.0
- secret formula <function secret_formula at 0x0000000003D1D1E0>
- Traceback (most recent call last):
- File "C:/Python33/PTHW24a.py", line 18, in <module>
- print ("We'd have {} beans, {} jars, and {} crates.".format (int(secret_formula(start_point))))
- TypeError: int() argument must be a string or a number, not 'tuple'
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement