python3.5.3rc1学习二

#if else示例
x = 5
y = 8

if x > y:
print("x is greater than y")
else:
print("x is not greater than y")

print("--------------")
#if-elif-else
x = 15
y = 18
z = 15

if x > y:
print("x is greater than y")
elif x < z:
print("x is less than z")
else:
print("上面两种条件都不执行,才执行此代码")
print("--------------")
#函数
def example():
print("basic function example")
z = 3 + 9
print(z)
example()
print("--------------")
#求两个数最大值
def twomax(a,b):
if a > b:
print("max is %s"%(a))
else:
print("max is %s"%(b))

twomax(3,8)
def threemax(x,y,z):
if x > y:
twomax(x,z)
else:
twomax(y,z)
threemax(12,18,45)

原文地址:https://www.cnblogs.com/51testing/p/7890375.html