大家好,欢迎来到IT知识分享网。
尝试是这样的注意psudeo代码和实际代码和之间的差异,因为你希望用户输入比较一个数字,你需要将字符串输入转换为INT:
import sys
def proc_withdrawal():
print(“Your proc_withdrawal code goes here”)
def proc_balance():
print(“Your proc_balance code goes here”)
def proc_pin():
print(“Your proc_pin code goes here”)
def proc_bills():
print(“Your proc_bills code goes here”)
def proc_cancel():
print(“Thank you for using Simon Raivid’s Cash Machine, Have a nice day!”)
sys.exit(0)
while True:
print(“Simon Raivid’s Cash Machine”)
print(“===========================”)
print(“\t1 – Cash withdrawal”)
print(“\t2 – Balance”)
print(“\t3 – PIN Services”)
print(“\t4 – Pay bills”)
print(“\t5 – Cancel”)
user_option = int(input(“Please select an option 1-5: “))
if user_option == 1:
proc_withdrawal()
elif user_option == 2:
proc_balance()
elif user_option == 3:
proc_pin()
elif user_option == 4:
proc_bills()
elif user_option == 5:
proc_cancel()
else:
print(“Please only enter an option 1, 2, 3, 4 or 5”)
实例应用:
Simon Raivid’s Cash Machine
===========================
1 – Cash withdrawal
2 – Balance
3 – PIN Services
4 – Pay bills
5 – Cancel
Please select an option 1-5: 4
Your proc_bills code goes here!
Simon Raivid’s Cash Machine
===========================
1 – Cash withdrawal
2 – Balance
3 – PIN Services
4 – Pay bills
5 – Cancel
Please select an option 1-5: 5
Thank you for using Simon Raivid’s Cash Machine, Have a nice day!
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/21820.html