python中主函数循环,带有菜单函数的Python主函数循环不起作用?

我现在是一名大学生,正在上python课程。我们的任务是用函数创建这个程序。main函数调用菜单,然后在main函数中编写一个循环,根据菜单函数中的用户响应访问其他函数。在

我好像不能让我的循环工作。当我选择一个菜单选项时,什么都不会发生。现在,我只有print语句来测试函数的调用。在我编写函数之前,我要确保它能正常工作。在

如果有人有一个循环调用函数应该是什么样的示例,这将对我有很大帮助。在def GetChoice():

#Function to present the user menu and get their choice

#local variables

UserChoice = str()

#Display menu and get choice

print()

print("Select one of the options listed below: ")

print("\tP\t==\tPrint Data")

print("\tA\t==\tGet Averages")

print("\tAZ\t==\tAverage Per Zone")

print("\tAL\t==\tAbove Levels by Zone")

print("\tBL\t==\tBelow Levels")

print("\tQ\t==\tQuit")

print()

UserChoice = input("Enter choice: ")

print()

UserChoice = UserChoice.upper()

return UserChoice

def PrintData():

print("test, test, test")

def AverageLevels():

print("test, test, test")

def AveragePerZone():

print("test, test, test")

def AboveLevels():

print("test, test, test")

def BelowLevels():

print("test, test, test")

def main():

Choice = str()

#call GetChoice function

GetChoice()

#Loop until user quits

if Choice == 'P':

PrintData()

elif Choice == 'A':

AverageLevels()

elif Choice == 'AZ':

AveragePerZone()

elif Choice == 'AL':

AboveLevels()

elif Choice == 'BL':

BelowLevels()

main()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值