Mar-17-2021, 10:53 AM
Hello guys I hope You will be able to help me with these simple functions. I can not understand and I tried everything.I spent couple days, watched videos etc. My main problem is I don’t know how to pass the choice from "option" frrom main() to the started(operation), and I don’t know how I should use the operator in the other function. I will add some instructions to the code so everyone can understand what I am talking about. Thank You in advance guys. Please for understanding.
def menu(): """ Task 2: Display a menu of options and read the user's response. A menu consisting of the following options should be displayed: 'Load Data', 'Process Data', 'Visualise Data', 'Save Data' and 'Exit' The user's response should be read in and returned as an integer corresponding to the selected option. For example, 1 for 'Load Data', 2 for 'Process Data' and so on. If the user enters a invalid option then a suitable error message should be displayed and the value None should be returned. :return: None if invalid selection otherwise an integer corresponding to a valid selection """ # TODO: My code print("\nWhat would You like to do ?") print(" \n 1- Load Data\n 2- Process Data\n 3- Visualise Data\n 4- Save Data\n 5- Exit ") option = int(input()) if option == 1: return option if option == 2: return option if option == 3: return option if option == 4: return option if option == 5: return option else: print("Invalid selection") return def started(operation): """ Task 3: Display a message to indicate that an operation has started. The function should display a message in the following format: '{operation} has started.' Where {operation} is the value of the parameter passed to this function :param operation: A string indicating the operation being started :return: Does not return anything """ # TODO: My code here operation = if operation == 1: print("Loading has started") menu() started()