python--条件判断和while循环组合(三)
# if条件分支+while循环 print('--------数字-------------') temp = input('说出我心中所想的数字:') cass = int(temp) while cass != 8: temp = input('猜错了,再猜一次吧<-->:') cass = int(temp) if cass==8: print('猜对了') else: if cass > 8: print('不对,你猜的数字大了') else: print('不对,你猜的数字小了') print('over') # and逻辑操作符:可以将任意表达式链接在一起,得到一个布尔表达式的值 temp = 1<2 and 2<3 print('判断and两边的表达式是否成立:',temp) temp = 1<2 and 2>3 print('判断and两边的表达式是否成立:',temp)