Question

In: Computer Science

Python programming: Instructions: The python program should respond to user input on a command line Below...

Python programming:

Instructions:

  • The python program should respond to user input on a command line
  • Below are the four options
    - if the user input is A, the program will quit
    -if the user input is B, the program will display the number of times the prompt has been displayed
    -if the user input is C, will display whatever is stored.
    -if the user inputs something else, it will store that user input as a string and append it to the already stored data.

Solutions

Expert Solution

count = 0
data = ""
while True:
    print("A. quit")
    print("B. display the number of times the prompt has been displayed")
    print("C. display whatever is stored")
    print("Something else to add data to the already stored data")
    choice = input("Enter your choice: ")
    count += 1
    if choice == "A":
        break
    elif choice == "B":
        print("Number of times count has been displayed is", count)
    elif choice == "C":
        print(data)
    else:
        data += choice





Related Solutions

Instructions JAVA PROGRAMMING 1. Ask the user for a year input (positive integer - should be...
Instructions JAVA PROGRAMMING 1. Ask the user for a year input (positive integer - should be between 1500 and 2019, inclusive). 2. If the year input is not between 1500 and 2019, do not check for leap year, rather print that this year cannot be checked. 3. Take a year input from the user (should be between 1500 and 2019) 4. If the input year is a leap year, print that year is a leap year; otherwise, print that the...
Create a python program that will: prompt a user for a command Command get_data Level 1:...
Create a python program that will: prompt a user for a command Command get_data Level 1: Take one of the commands my_max my_min my_range my_sum mean median mode fib factorize prime Requirements: Your commands should be case-insensitive You should use python lists to store data You should NOT use built-in python math functions, or math libraries to compute these values Tips: Write one function that will convert a string with comma-separated numbers into a python list with the numbers. You...
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input...
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x)...
Twin elements Create a program that: Input: Receive as input in command line the sizes m...
Twin elements Create a program that: Input: Receive as input in command line the sizes m and n of a two dimensional array Receive as input in command line the minValue and maxValue between which the random numbers will be generated for your two dimensional array Generate: Generate a two-dimensional with numbers between minValue and maxValue (inclusive) with the given size (mxn) Compute: Compute the number of elements that have a neighbour (up, down, left or right) with the same...
IN PYTHON create a python program that accepts input from the user in the following sequence:...
IN PYTHON create a python program that accepts input from the user in the following sequence: 1. Planet Name 2. Planet Gravitational Force(g) for data, use the planets of our solar system. The data input is to be written in 2 separate lists, the names of which are: 1. planetName 2. planet GravitationalForce(g) A third list is required that will store the weight of a person with mass of 100kg, the formula of which is: W=mg(where m is mass of...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
Python Program 1: Write a program that takes user input in the form of a string...
Python Program 1: Write a program that takes user input in the form of a string Break up the string into a list of characters Store the characters in a dictionary The key of the dictionary is the character The value of the dictionary is the count of times the letter appears Hint: remember to initialize each key before using Output of program is the count of each character/letter Sort the output by key (which is the character) Python Program...
Python Add a command to this chapter’s case study program that allows the user to view...
Python Add a command to this chapter’s case study program that allows the user to view the contents of a file in the current working directory. When the command is selected, the program should display a list of filenames and a prompt for the name of the file to be viewed. Be sure to include error recovery in the program. If the user enters a filename that does not exist they should be prompted to enter a filename that does...
JAVA Take in a user input. if user input is "Leap Year" your program should run...
JAVA Take in a user input. if user input is "Leap Year" your program should run exercise 1 if user input is "word count" your program should run exercise 2 Both exercises should run in separate methods Exercise 1: write a java method to check whether a year(integer) entered by the user is a leap year or not. Exercise 2: Write a java method to count all words in a string.
Minimum value and its position Create a program that: Receive as input in command line the...
Minimum value and its position Create a program that: Receive as input in command line the sizes m and n of a two dimensional array, and minValue and maxValue between which the random numbers will be generated Generate a array with numbers between minValue and maxValue (inclusive) with the given size (mxn) Compute the minimum value in the array and one of the rows and columns on which it appears. Print the array as a table. Print the minimum value...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT