Files
python/python_03_判断语句.py
2025-08-05 09:19:34 +08:00

38 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 布尔类型
# result = "dog"
# result1 = "cat"
# print(f"{result == result1}")
# print(result >= result1)#只比较首字母ascii值,不比较后续的值
# # if语句
# age=30
# if age >= 18:
# print("我已经成年了\n即将步入大学生活")
# if elif else多条件判断
# height=int(input("请输入你的身高(cm"))
# VIP_level=int(input("请输入您的VIP等级(1-5"))
#
# if height < 120:
# print("您的身高小于120cm,可以免费")
# elif VIP_level > 3:
# print("您的vip等级大于3,可以免费")
# else:
# print("需要请买票10元")
# 单次输入一行写法
# if int(input("请输入你的身高(cm"))<120:
# print("您的身高小于120cm,可以免费")
# elif int(input("请输入您的VIP等级(1-5"))>3:
# print("您的vip等级大于3,可以免费")
# else:
# print("需要请买票10元")
#嵌套方式
if int(input("请输入你的身高(cm"))>120:
print("身高超出限制,不可以免费")
print("如果vip大于3则可以免费")
if int(input("请输入您的VIP等级(1-5"))>3:
print("您的vip等级大于3,可以免费")
else:
print("对不起,您不能免费")
else:
print("身高未超出限制,可以免费")