根据书中的PowerShell运行结果,进行仿写
beans,jars,crates = secret_formula(start_point) # 函数运算结果存储方式一 print(f"We'd have {beans} beans, {jars} jars, and {crates} crates.")
formula = secret_formula(start_point) # 两种函数运算结果存储方式
print("We can also do that this way:\nWe'd have {} beans,{} jars, and {} crates.".format(*formula))1 print("Let's practice everything.") 2 print("You'd need to know 'bout escapes with \\ that do: \n\n newlines and \ttabs.") 3 4 peom =''' 5 The lovely world 6 with logic so firmly planted\ncannot discern\n the needs of love 7 nor comprehend passion from intuition 8 and requires an explanation 9 \n\t\twhere there is none. 10 ''' 11 print("-"*14) 12 print(peom) 13 print("-"*14) 14 15 five = 10-2+6-9 16 17 print("This should be five:{}".format(five)) 18 19 def secret_formula(vkkk): 20 jelly_beans = vkkk * 500 21 jars = jelly_beans/1000 22 crates = jars / 100 23 return jelly_beans, jars, crates 24 25 start_point = 10000 26 beans,jars,crates = secret_formula(start_point) 27 28 print("With a starting point of:{}".format(start_point)) 29 print(f"We'd have {beans} beans, {jars} jars, and {crates} crates.") 30 31 start_point = 10000/10 32 formula = secret_formula(start_point) 33 print("We can also do that this way:\nWe'd have {} beans,{} jars, and {} crates.".format(*formula))
PS C:\Users\Administrator\lpthw> python ex24.py Let's practice everything. You'd need to know 'bout escapes with \ that do: newlines and tabs. -------------- The lovely world with logic so firmly planted cannot discern the needs of love nor comprehend passion from intuition and requires an explanation where there is none. -------------- This should be five:5 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: We'd have 500000.0 beans,500.0 jars, and 5.0 crates.
标签:24,笨办法,point,crates,beans,print,formula,习题,jars From: https://www.cnblogs.com/luxiaoli/p/17744881.html