标签:数值 比较 NPU 条件 网站 注意 int font soft
一、判断
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‘)
标签:数值 比较 NPU 条件 网站 注意 int font soft
原文地址:https://www.cnblogs.com/qy1234/p/9352950.html