首页 > 代码库 > ex24.py

ex24.py

 1 # -*- coding:utf-8 -*-
 2 print ("Let‘s practice everything.")
 3 print (You\‘d need to know \‘bout escapes with \\ that do \n newlines and \t  tabs.)
 4 
 5 ‘‘‘poem = """
 6 \tThe lovely world
 7 with logic so firmly planted
 8 cannot discern \n the needs of love
 9 nor comprehend passion from intuition
10 and requires an explanation
11 \n\t\twhere there is none.
12 """
13 ‘‘‘
14 poem = input("\n>>>>>")
15 print ("--------------")
16 print (poem)    #python3 中变量也需要打()
17 print ("--------------")
18 
19 
20 five = 10 - 2 + 3 - 6
21 print("This should be five: %s" % five)
22 
23 def secret_formula(started):
24     jelly_beans = started * 500
25     jars = jelly_beans / 1000
26     crates = jars / 100
27     return jelly_beans, jars, crates
28 
29     
30 start_point = int(input("start_point?\n>>>>"))
31 beans, jars, crates = secret_formula(start_point)   #注意本行的用法
32 print ("With a starting point of: %d" % start_point)
33 print ("we‘d have %d beans, %d jars, and %d crates." % (beans,jars,crates))
34 
35 start_point = start_point / 10
36 
37 print("We can also do that this way:")
38 
39 print("we‘d have %d beans, %d jars, and %d crates." % secret_formula(start_point))
40 
41 
42     

 

ex24.py