Question

In: Computer Science

print("1. Change Team: ") print("2. Choose Position") print("3. Quit") imp = input("Choose an option: ") if...

print("1. Change Team: ")
print("2. Choose Position")
print("3. Quit")
imp = input("Choose an option: ")
if imp == 1:
    chooseTeam()
elif imp == 2:
    choosePosition()
elif imp == 3:
    print("Goodbye")
else:
    print("Invalid option")
    imp2 = input("Choose an option (1-3): ")

This is my current code however I want it to loop back up to the top if an invalid option is input so it can reset the function

Solutions

Expert Solution

PYTHON CODE:

# Sample function for demonstration purpose only
def chooseTeam():
    print('Inside chooseTeam() function')
# Sample function for demonstration purpose only
def choosePosition():
    print('Inside choosePosition() function')
#############################################
#   Actual code goes here
#############################################
print("1. Change Team: ")
print("2. Choose Position")
print("3. Quit")
imp = int(input("Choose an option: "))
# Loop indefinitely till user enters 3 to exit
while True:
    if imp == 1:
        chooseTeam()
    elif imp == 2:
        choosePosition()
    elif imp == 3:
        print("Goodbye")
        break
    else:
        # If user entered invalid option print this msg
        print("Invalid option.")
        imp = int(input("Choose an option (1-3): "))
        # Skip the remaining part of the loop and go to top
        continue
    print("1. Change Team: ")
    print("2. Choose Position")
    print("3. Quit")
    imp = int(input("Choose an option: "))

SAMPLE OUTPUT:

FOR ANY HELP JUST DROP A COMMENT


Related Solutions

using python 3 1. Two-line input: print a prompt (e.g Enter your first name) and then...
using python 3 1. Two-line input: print a prompt (e.g Enter your first name) and then assign the input to a variable print ("Enter your first name")# the word prompt is the message the user should see firstName = input() print (firstName)
1. Motion is a process of (a) a change in time, (b) a change in position,...
1. Motion is a process of (a) a change in time, (b) a change in position, (c) a change in weight, (d) a change in mass. 2. Which of the following is a scalar quantity? (a) force, (b) speed, (c) velocity,               (d) acceleration. 3. The time rate of change of velocity is (a) speed, (b) acceleration, (c) friction,            (d) force. 4. In addition to a magnitude, a vector quantity has (a) time, (b) direction,                 (c) length, (d) an average value....
Write java program that will ask for the user for 2 input lines and print out...
Write java program that will ask for the user for 2 input lines and print out all words that occur 1 or more times on both lines (case sensitive). Write this without arrays and method. Here is a sample run: <Output> Enter two lines to process. The quick brown fox jumps over a lazy dog The fox hound outruns the lazy dog The words that occur on both lines are: The fox lazy dog
PYTHON 1- First, initialize the constant NUMS as 3: NUMS=3 2- Print the title of the...
PYTHON 1- First, initialize the constant NUMS as 3: NUMS=3 2- Print the title of the application. >---=== Python Temperature Analyzer ===---< 3- Using a for loop, prompt the user to enter the high and low values for each of NUMS days. The values entered must be between -40 and 40, and high must be greater than low. Print the following messages: > * Read the high value. > Enter the high value for day 1: < (or day 2,...
Input Format 4 1 2 3 4 Constraints there will be no more than 50 input...
Input Format 4 1 2 3 4 Constraints there will be no more than 50 input numbers. Output Format Odd: 2 Even: 2 Divisible by 7: 0 Average: 250 Sample Input 0 4 1 2 3 4 Sample Output 0 Odd: 2 Even: 2 Divisible by 7: 0 Average: 250 import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution {     public static void main(String[] args) throws IOException {         BufferedReader bufferedReader = new...
Find the net change of ?(?) = (? − 2)(? + 3) on the interval [-1,...
Find the net change of ?(?) = (? − 2)(? + 3) on the interval [-1, 1]. Find the net change of ?(?) = 6 cos ? on the interval [−? /2, ?/2]. Find the total area between ?(?) = ?3 − 2?2 and the x-axis on the interval [0, 5]. A ball is thrown upward from a height of 5 feet at an initial speed of 72 ft/sec. Acceleration resulting from gravity is -32 ft/sec2. Neglecting air resistance, find...
Choose T/F for the following: (a) Gamma measures the option price change when the stock price...
Choose T/F for the following: (a) Gamma measures the option price change when the stock price increases. (b) Vega measures the change in the option price when there is an increase in volatility. (c) Theta measures the change in the option price when there is an increase in the time to maturity. (d) Rho measures the change in the option price when there is an increase in the interest rate. (e) For a call option, delta is not negative. (f)...
Use Python: Develop neurons and print truth table of the following 2-input logic gates: AND, OR,...
Use Python: Develop neurons and print truth table of the following 2-input logic gates: AND, OR, NAND, NOR, XOR, XNOR and 1-input NOT gate (Notice: use Markdown to explain how you developed a neuron, and to insert images showing the truth table of logic gates before coding)
You accepted a position at the company to lead a team of 3 multi-media developers (excluding...
You accepted a position at the company to lead a team of 3 multi-media developers (excluding yourself). This team will be responsible for graphic design, animations, and promotional material. Your role is to manage the team members, their hardware and software needs, and projects. Your employer asks you to assess the HARDWARE needs for the team and propose a computer configuration that would meet the functions of the team yet the least expensive. Based on the information that you were...
1. Find the mean and standard deviation for option 1 and option 2 Option 1: Year...
1. Find the mean and standard deviation for option 1 and option 2 Option 1: Year Return 1 15 % 2 -12 % 3 8 % 4 11 % Option 2: Prob. Return 0.05 16 % 0.40 8 % 0.25 -6 % 0.30 7 %
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT