Could you help to figure out why my Python code is not working? I'm trying to create a code that asks the user to enter a numerical value, if the user enters a value, for example, one instead of ("1") then a message should show up "Numerical value expected".
Phyton code below:
def handle_errors():
name = input("Enter your name")
status = False
while not status
try:
x = int(input("Enter number x:"))
y: int = int(input("Enter number y:"))
sum = x + y
print("Your name is", name)
print("The sum of", x, "and", y, "is", sum)
break:
except:
print("Invalid input! Numeric value expected.")
pass
handle_errors()
#function handle_errors
def handle_errors():
#prompt for name
name = input("Enter your name: ")
#initialize status as False
status = False
#loop to read numbers and process output
while not status:
#try block
try:
#prompt for number x
x = int(input("Enter number x: "))
#prompt for number y
y = int(input("Enter number y: "))
#calculating sum
sum = x + y
#printing name
print("Your name is", name)
#printing sum of x and y
print("The sum of", x, "and", y, "is", sum)
#exits the loop
break
#if invalid input
except:
#printing error message
print("Invalid input! Numeric value expected.")
#calling function handle_errors
handle_errors()
Step by stepSolved in 2 steps with 2 images
- In C# code: Write a program that will help an elementary schoolstudent learn multiplication. Use a Random object to produce two positive one-digitintegers. The program should then prompt the user with a question, such asHow much is 6 times 7 The student then inputs the answer. Next, the program checks the student’s answer. Ifit’s correct, display the message "Very good!" and ask another multiplication question.If the answer is wrong, display the message "No. Please try again." and let the studenttry the same question repeatedly until the student gets it right. A separate methodshould be used to generate each new question. This method should be called oncewhen the app begins execution and each time the user answers the question correctly.Program will stop any time students enter -1. One problem in CAI environments is student fatigue. This can be reduced by varyingthe computer’s responses to hold the student’s attention. The program should usevarious comments to be displayed for each…arrow_forwardDesign and implement an application that plays the Hi-Lo guessing game with numbers. The program should pick a random number between 1 and 100 (inclusive) and then repeatedly prompt the user to guess the number. On each guess, report to the user that he or she is correct or that the guess is high or low. Continue accepting guesses until the user guesses correctly or chooses to quit. Use a sentinel value to determine whether the user wants to quit. Count the number of guesses, and report that value when the user guesses correctly. At the end of each game (by quitting or a correct guess), prompt to determine whether the user wants to play again. Continue playing games until the user chooses to stop.arrow_forwardin Java languagearrow_forward
- Help me debug this exercise using Javaarrow_forwardDevelop a program that allows the user to enter a start value of 1 to 4, a stop value of 5 to 12 and a multiplier of 2 to 8. The program must display a multiplication table with results using these values. For example, if the user enters a start value of 3, a stop value of 7 and a multiplier value of 3, the table should be displayed as follows: Multiplication Table 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 additionally Each multiplication problem must be displayed with a problem number. The program must prompt the user to enter an answer to each of the multiplication problems. The correct answer should be displayed after the user enters an answer. A message should be displayed informing the user that the answer entered was correct or incorrect followed by an appropriate motivating comment. A running record of the number of correct and incorrect responses must be kept. After all the problems have been presented the user must be informed of his/her performance; number of…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY