廖雪峰网站:学习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')

 

posted @ 2018-07-23 09:05  笑笑未来  阅读(228)  评论(0编辑  收藏  举报