首页 > 其他 > 详细

ex24.py

时间:2016-11-21 12:27:23      阅读:169      评论:0      收藏:0      [点我收藏+]
 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

原文:http://www.cnblogs.com/jiangzhipeng/p/6084874.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!