-
判断姑娘年龄
age_inp = int(input('请输入姑娘的年龄:')) if age_inp < 18: print('不接受未成年') elif age_inp>=18 and age_inp<25: print('心动表白') elif age_inp>=25 and age_inp <45: print('阿姨好') else: print('奶奶好')
-
打印1-100之间的奇数和
count=0 s=0 while count<100: if count%2==1: s+=count count += 1 print(s)
-
猜年龄游戏
count=0 age=20 while count<3: age_inp=int(input('请输入年龄:》》')) if age_inp==age: print('猜对了') break elif age_inp > age: print('猜大了') else: print('猜小了') count+=1 print(f'你还有{3-count}次机会!!') if count==3: choice_inp=input('游戏结束,输入Y或y就可以重新开始,输入N或n则退出游戏:') if choice_inp in ['Y','y']: count=0 else: pass