廖雪峰网站:学习python基础知识—判断(三)
一、判断
1、条件判断
age = 18 if age >= 18: print('your are is', age) print('adult') age = 3 if age >= 18: print('your are is', age) print('adult') elif age >= 6: print('your are is', age) print('Sarah') elif age >= 3: print('your are is', age) print('Jack') else: print('your are is', age) print('mike') # 注意: # input()返回的是字符串 # 必须通过int()将字符串转换为整数 # 才能用于数值比较: age = int(input('Input your age:')) if age >= 18: print('your are is', age) print('adult') elif age >= 6: print('your are is', age) print('Sarah') elif age >= 5: print('your are is', age) print('Jack') else: print('your are is', age) print('mike')
我是一个爱笑,认真记录每一天进步的博主.
转载请注明出处,商用请征得作者本人同意,谢谢!!!