码迷,mamicode.com
首页 > 其他好文 > 详细

ex24.py

时间:2016-11-21 12:29:12      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:esc   lin   exp   注意   orm   a star   starting   code   can   

 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

标签:esc   lin   exp   注意   orm   a star   starting   code   can   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!