python05 if or and 的使用

# if or 的使用
you = input("你去吗?")  # 去或者不去
wife = input("你老婆去吗?")  # 去或者不去
if you == "去" or wife == "去":
    print("你和你老婆有一个去啦,A事情办成了")
# if and 的使用
if you == "去" and wife == "去":
    print("你和你老婆都去了,B事情办成了")
#  白富美测试
color = input("你白么?")  # 白或者黄
money = int(input("你富有?"))  # 1000
beautiful = input("你美么?")  # 美
if color == "白" and money >= 100000000 and beautiful == "美":
    print("白富美")
else:
    print("矮穷矬")

注意事项

因为一共四个语句,要么都不执行,要么都执行,那么这就是一个语句。(python 是根据tab键来进行判断的关系的)

color = input("你白么?") #白 或者 黄

money = int(input("请输入你的财产总和:")) #输入1000

beautiful = input("你美么?")#美 或者 普通

 

if color=="白" and money>1000000 and beautiful=="美":

    print("白富美....")

    print("好羡慕......")

else:

    print("矮矬穷....")

 

#下面的代码 不会因为上面第5行的if条件满足或者不满足而不一样,即 他们之间没有任何关系

print("矮矬穷....")

print("矮矬穷....")

print("矮矬穷....")

'''
not 的使用

'''

if not (color == "白" and money >= 100000000 and beautiful == "美"):
    print("矮穷矬")
    print("矮穷矬")
else:
    print("白富美")
    print("好羡慕")
  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值