#比较大小#name:maxNumber.py#比较两个数大小#C:\Users\Anthony\AppData\Local\Programs\Python\Python36-32\Lib\site-packagesdef maxTwo(x,y): if x > y: print(x) else: print(y) def maxThree(x,y,z): if x > y: maxTwo(x,z) else: maxTwo(y,z)…
##全局变量与局部变量x = 6 def printFuc(): y = 8 z =9 print(y + z) print(x) printFuc()#print(y)#常见错误##name = "Anthony"##print(Name) #文件写入 text = "Sample Text to Save \nNew Line" """调用buid-in函数:open打开或者创建文件, 如果exampleFile.txt不存在,就自…
class calculator: def add(x,y): return x + y print(added) def sub(x,y): return x - y print(sub) def mul(x,y): return x * y print(mul) def div(x,y): return x / y print(div) print (calculator.mul(3,5))print (calculator.add(3,5)) # 少写参数或者不写,会报错 # calcul…
#if else示例x = 5y = 8 if x > y: print("x is greater than y")else: print("x is not greater than y") print("--------------")#if-elif-elsex = 15y = 18z = 15 if x > y: print("x is greater than y")elif x < z: pri…