Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the code snippets below consist of a function that takes two numbers as an input ( initially strings ) and then checks whether the second

the code snippets below consist of a function that takes two numbers as an input (initially strings) and then checks whether the second number is a multiple of the first number.
# A program which checks if num_2 is a multiple of num_1
def check_if_multiple():
try:
num_1= int(input('Enter first number: '))
num_2= int(input('Enter first number: '))
if num_2% num_1==0:
print('True')
else:
print('False')
except Exception as obj:
print('Generic Exception Handler')
except ValueError as obj:
print('Expected Integer input')
print('__!String value founded!__')
Now, lets say a user gave the input for num_1 and num_2 as '12' and Steve, respectively. What will the output be?
The code will successfully run and show the following output:
Expected Integer input
__!String value founded!__
The program will crash because we are giving a string for the integer input.
The code will successfully run and show the following output:
Generic Exception Handler
The code will successfully run and show the output below:
False

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions