首页 > 代码库 > 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。