Day 02

#1、判断下列逻辑语句的True,False.  True
#1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
#2)not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 False
# 2、求出下列逻辑语句的值。
# 1),8 or 3 and 4 or 2 and 0 or 9 and 7 8
# 2),0 or 2 and 3 and 4 or 6 and 0 or 3 4
# 3、下列结果是什么?
# 1)、6 or 2 > 1 6
# 2)、3 or 2 > 1 3
# 3)、0 or 5 < 4 False
# 4)、5 < 4 or 3 5
# 5)、2 > 1 or 6 2
# 6)、3 and 2 > 1 True
# 7)、0 and 3 > 1 0
# 8)、2 > 1 and 3 True
# 9)、3 > 1 and 0 True
# 10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2 2
# 4、while循环语句基本结构?
""" while 条件:
代码块
break
continue
else:
代码块"""
# 5、利⽤while语句写出猜⼤⼩的游戏:
# 设定⼀个理想数字⽐如:66,让⽤户输⼊数字,如果⽐66⼤,则显示猜测
# 的结果⼤了;如果⽐66⼩,则显示猜测的结果⼩了;只有等于66,显示猜测结果
# 正确,然后退出循环。
''' while True:
num=int(input("请输入一个数字"))
if num>66:
print("大了")
elif num<66:
print("小了")
else:
print("正确")
break'''
# 6、在5题的基础上进⾏升级:
# 给⽤户三次猜测机会,如果三次之内猜测对了,则显示猜测正确,退出循
# 环,如果三次之内没有猜测正确,则⾃动退出循环,并显示‘太笨了你....’。
'''
count=3
while count>0:
count =count-1

num=int(input("请输入一个数字"))
if num>66:
print("大了")
elif num<66:
print("小了")
else:
print("正确")

break
else:
print("你太笨了")'''
# 7.使⽤while循环输⼊ 1 2 3 4 5 6 8 9 10
'''
count=0
while count<11:
if count !=7:
print(count)
count = count + 1'''
# 8.求1-100的所有数的和
'''
count=1
num=0
while count<=100:
num=count+num
count=count+1
print(num)'''
# 9.输出 1-100 内的所有奇数
'''
num=1
while num<=100:
print(num)
num=num+2'''
# 10.输出 1-100 内的所有偶数
'''
num=2
while num<=100:
print(num)
num+=2'''
# 11.求1-2+3-4+5 ... 99的所有数的和.
'''

count = 1
num = 0
while count <= 99:
if count % 2 == 1:
num += count
else:
num -= count
count += 1
print(num)'''
# 12.⽤户登陆(三次输错机会)且每次输错误时显示剩余错误次数(提示:使⽤
# 字符串格式化)
'''
count=3
while count>0:
count-=1
a = input("请输入你的账户")
num = input("请输入你的密码")
if a == "麻花藤" and num == "456":
print("登录成功")
else :
print("你还有%s次机会"% (count))'''

# 14. 输⼊⼀个⼴告标语. 判断这个⼴告是否合法. 根据最新的⼴告法来判断. ⼴
# 告法内容过多. 我们就判断是否包含'最', '第⼀', '稀缺', '国家级'等字样. 如果包
# 含. 提示, ⼴告不合法
#            例如, 1. ⽼男孩python世界第⼀. ==> 不合法
#                   2. 今年过年不收礼啊. 收礼只收脑⽩⾦. ==> 合法
'''
add = input("请输入一则广告语")#"第"一,稀缺,国家级
if "最" in add or "第一" in add or "稀缺" in add or "国家级" in add :
print("不合法")
else:
print("合法")'''

猜你喜欢

转载自www.cnblogs.com/lhn54843626/p/9587983.html