Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

If your python script contains two or more functionalities, how can you run the script continuously to allow the user to select any one of these functionalities without restarting your program in a...

1 answer below »
If your python script contains two or more functionalities, how can you run the script continuously to allow the user to select any one of these functionalities without restarting your program in a new IDLE console?
Answered 1 days After Mar 20, 2021

Solution

Pratap answered on Mar 21 2021
145 Votes
How to run a script until the user quits:
Let us consider two functions in a program. One will perform a task like math calculation or printing a desired string, list etc. Another will be the one which asks the user whether or not to continue the task.
Example #1:
    def task_to_perform():
        “””function body with some math
        operation or print statements”””
        print(some_result)
        user_input()
    def user_input():
        var = input(“Enter ‘Y’ to perform another task or ‘N’ to stop: “)
        if var == ‘Y’:
            task_to_perform()
        elif var ==...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here