Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q4 (4 pts) Write a Python program to play a basic game: user guesses a number, and the program compares it to a randomly generated
Q4 (4 pts) Write a Python program to play a basic game: user guesses a number, and the program compares it to a randomly generated number to see if they match. Use the following steps: Note: Double click this cell to see the pseudocode formatted with indentations. Prompt the user for his or her name and get the and store it in a variable called player_name If the name is blank, print a message and exit. Print a welcome message to the user that includes his or her name Prompt the user to guess a number between 0 and 100; store it as an int in a variable called user_number. Import the random library, then generate a random integer between 0 and 100, and store it in a variable called computer_number If user_number is less than computer_number print "Sorry, [insert player_name]. You guessed too low! [insert user_number] is less than [insert computer_number]." If user_number is equal to computer_number print "Correct, [insert player_name! You guessed that I am thinking of the number [insert computer number]." If user_number is greater than computer number print "Sorry, [insert player_name]! Your guess is too high! [insert user_number] is higher than [insert computer_number]." In [ ]: # Enter your code for question 4 here Q5 (4 pts) Write pseudocode and Python code for a program that takes the user's age as input and prints a ticket price (depending on their age) A movie theater charges different ticket prices depending on a person's age. If a person is under the age of 3, the ticket is free; if they are between 3 and 12, the ticket is 10; and if they are over age 12, the ticket is 15. Write a program in which you ask users their age, and tell them the cost of their movie ticket. In your code, the prompt for the user's age should be "What is your age?", and the output should be of the form "Please pay $amount for the ticket. In [ ]: # write your pseudocode for question 5 here In : # enter your code for guestion 5 here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started