NP43 判断布尔值
num=int(input())
if num==1:
print("Hello World!")
elif num==0:
print("Erros!")
NP44 判断列表是否为空
my_list=[]
if len(my_list)==0:
print("my_list is empty!")
else:
print("my_list is not empty!")
NP45 禁止重复注册
current_users=["Niuniu","Niumei","GURR","LOLO"]
new_users=["GurR","Niu Ke Le","LoLo","Tuo Rui Chi"]
current_users_l=[user.lower() for user in current_users]
for user in new_users:
if user.lower() in current_users_l:
print(f"The user name {user} has already been registered! Please change it and try again!")
else:
print(f"Congratulations, the user name {user} is available!")
NP46 菜品的价格
name=input()
if name=="pizza":
print(10)
elif name=="rice":
print(2)
elif name=="yogurt":
print(5)
else:
print(8)
NP47 牛牛的绩点
my_dict={"A":4.0,"B":3.0,"C":2.0,"D":1.0,"F":0}
count1=0
count2=0
while True:
course=input()
if course=="False":
break
else:
num=int(input())
count1+=num*my_dict[course]
count2+=num
print("%.2f" %(count1/count2))
NP48 验证登录名与密码
my_dict={"name":"admis","passwd":"Nowcoder666"}
username=input()
password=input()
if username==my_dict["name"] and password==my_dict["passwd"]:
print("Welcome!")
else:
print("user id or password is not correct!")