大佬教程收集整理的这篇文章主要介绍了使用 not in 和 in - Python,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
small_pizza = 15 medium_pizza = 20 large_pizza = 25 pepperoni_small_pizza = 2 pepperoni_med_or_large_pizza = 3 extra_cheese = 1 print("Welcome to Pizza Palace") print("Thank you for choosing us.") pizza_size = input("Which size pizza would you like 1) small 2) Medium 3) Large :") if pizza_size == "1" or "small": pepperoni = input(f"Would you like to add pepperoni for ${pepperoni_small_pizza} :") cheese = input(f"Would you like to add extra cheese for ${extra_cheesE} :") if pepperoni and cheese in ["Y","y","Yes","yes","YES"]: bill = small_pizza + pepperoni_small_pizza + extra_cheese print(f"Thank you,your @R_102_10586@l bill is ${Bill}.") elif pepperoni in ["Y","YES"] and cheese in ["N","n","No","NO","no"]: bill = small_pizza + pepperoni_small_pizza print(f"Your @R_102_10586@l bill is ${Bill}.") elif pepperoni in ["N","no"] and cheese in ["Y","YES"]: bill = small_pizza + extra_cheese print(f"Your @R_102_10586@l bill is ${Bill}.") elif cheese and pepperoni in ["N","no"]: bill = small_pizza print(f"Your bill is ${Bill}.")
@H_675_5@当我尝试使用以下输入运行此代码时:
i/p:1 年 y
o/p:
Welcome to Pizza Palace Thank you for choosing us. Which size pizza would you like 1) >small 2) Medium 3) Large :1 Would you like to add pepperoni for $2 :y Would you like to add extra cheese for $1 :y Thank you,your @R_102_10586@l bill is $18.
@H_675_5@i/p: 1 y n
o/p:
Welcome to Pizza Palace Thank you for choosing us. Which size pizza would you like 1) small 2) Medium 3) Large :1 Would you like to add pepperoni for $2 :y Would you like to add extra cheese for $1 :n Your @R_102_10586@l bill is $17.
@H_675_5@i/p: 1 n n
o/p:
Welcome to Pizza Palace Thank you for choosing us. Which size pizza would you like 1) >small 2) Medium 3) Large :1 Would you like to add pepperoni for $2 :n Would you like to add extra cheese for$1 :n Your bill is $15.
@H_675_5@但是使用 i/p:
1 年 y
o/p: Welcome to Pizza Palace Thank you for choosing us. Which size pizza would you like 1) small 2) Medium 3) Large :1 Would you like to add pepperoni for $2 :n Would you like to add extra cheese for $1 :y Thank you,your @R_102_10586@l bill is $18.
@H_675_5@为什么会这样? 任何人都可以帮我解决这个问题吗?
当我输入意大利辣香肠:n 和奶酪:y
第三个 if 案例应该接管,但为什么第一个 if 案例是意大利辣香肠和奶酪 y 是否正在执行。
当使用“and”时,只有当意大利辣香肠和 奶酪是真的。
为什么即使一个陈述为假,条件也成立 执行了吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
大佬总结
以上是大佬教程为你收集整理的使用 not in 和 in - Python全部内容,希望文章能够帮你解决使用 not in 和 in - Python所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。