Answered step by step
Verified Expert Solution
Question
1 Approved Answer
urgent, could you please help me with these questions ? thanks This code has a syntax problem related to the exception catching: def broken_code(my_string): split_string
urgent, could you please help me with these questions ? thanks
This code has a syntax problem related to the exception catching: def broken_code(my_string): split_string = my_string.split(",") return split_string[0] except Exception as ex: print("Unable to split string + split_string) What is the problem? Select one O a. There is no try block - our try/except structure requires both a try and an except block. b. In the except block we must name the exception as 'e' not as 'ex' c. The code does not specify the kind of exception to catch d. There is no return statement in the except block. we need to have returns both inside and outside the except block Trun the following code, and when prompted to enter an integer', type in the word "banana' - what happens next? def prompt_the_user(): response = "" while response == ": try: response = input("Enter an integer: ") int_value = int(response) print("Your number multiplied by two is: " + str(int_value*2)) except Exception as e: print("That value wasn't acceptable, because of an exception: " + strie response = prompt_the_user() Select one a. The code prints That value wasn't acceptable, because of an exception: invalid literal for into with base 10. "banana' And then exits gracefully b The code exits with a runtime error 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