please fix the issue hihlighted in yellow and please check my code.   In python language: Write a program that reads integers user_num and div_num as input, and output the quotient (user_num divided by div_num). Use a try block to perform all the statements. Use an except block to catch any ZeroDivisionError and output an exception message. Use another except block to catch any ValueError caused by invalid input and output an exception message. Note: ZeroDivisionError is thrown when a division by zero happens. ValueError is thrown when a user enters a value of different data type than what is defined in the program. Do not include code to throw any exception in the program. Ex: If the input of the program is: 15 3 the output of the program is: 5 Ex: If the input of the program is: 10 0 the output of the program is: Zero Division Exception: integer division or modulo by zero Ex: If the input of the program is: 15.5 5 the output of the program is: Input Exception: invalid literal for int() with base 10: '15.5'   for my code and expected result please check the image.   thanks

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 9PP
icon
Related questions
Question

please fix the issue hihlighted in yellow and please check my code.

 

In python language:

Write a program that reads integers user_num and div_num as input, and output the quotient (user_num divided by div_num). Use a try block to perform all the statements. Use an except block to catch any ZeroDivisionError and output an exception message. Use another except block to catch any ValueError caused by invalid input and output an exception message.

Note: ZeroDivisionError is thrown when a division by zero happens. ValueError is thrown when a user enters a value of different data type than what is defined in the program. Do not include code to throw any exception in the program.

Ex: If the input of the program is:

15 3

the output of the program is:

5

Ex: If the input of the program is:

10 0

the output of the program is:

Zero Division Exception: integer division or modulo by zero

Ex: If the input of the program is:

15.5 5

the output of the program is:

Input Exception: invalid literal for int() with base 10: '15.5'

 

for my code and expected result please check the image.

 

thanks

1:Compare output A
Input
Your output 5
2:Compare output A
Input
3:Compare output A
Your output Zero Division Exception: integer division or modulo by zero
Input
Output differs. See highlights below.
Your output
Expected output
4:Compare outgut A
Input
Your output
Expected output
Output differs. See highlights below.
5:Compare output A
Input
Your output
15
3
Expected output
6:Compare output A
15
0
Input
Output differs. See highlights below.
7:Compare output A
15.5
5
Input
Input Exception: invalid literal for int() with base 10: 15.5
Input Exception: invalid literal for int() with base 10: 15.5"
25
0.5
Input Exception: invalid literal for int() with base 10: 25
Input Exception: invalid literal for int() with base 10: "0.5*
twenty
5
Input Exception: invalid literal for int() with base 10: twenty
Input Exception: invalid literal for int() with base 10: "twenty"
Your output 0
0
4
15
0
Your output Zero Division Exception: integer division or modulo by zero
2/2
0/1
1/1
1/1
Transcribed Image Text:1:Compare output A Input Your output 5 2:Compare output A Input 3:Compare output A Your output Zero Division Exception: integer division or modulo by zero Input Output differs. See highlights below. Your output Expected output 4:Compare outgut A Input Your output Expected output Output differs. See highlights below. 5:Compare output A Input Your output 15 3 Expected output 6:Compare output A 15 0 Input Output differs. See highlights below. 7:Compare output A 15.5 5 Input Input Exception: invalid literal for int() with base 10: 15.5 Input Exception: invalid literal for int() with base 10: 15.5" 25 0.5 Input Exception: invalid literal for int() with base 10: 25 Input Exception: invalid literal for int() with base 10: "0.5* twenty 5 Input Exception: invalid literal for int() with base 10: twenty Input Exception: invalid literal for int() with base 10: "twenty" Your output 0 0 4 15 0 Your output Zero Division Exception: integer division or modulo by zero 2/2 0/1 1/1 1/1
1 # user input
2
3 div_num=input()
4
5 # try block
6 try:
7
8
user_num=input()
11
12
# converting the input to int
user_num= int(user_num)
9 div_num= int(div_num)
10
quotient = user_num // div_num
print (quotient)
13 except ZeroDivisionError:
14
main.py
print('Zero Division Exception: integer division or modulo by zero')
15 except valueError:
16
print('Input Exception: invalid literal for int() with base 10:', '{}'.format(user_num))
Transcribed Image Text:1 # user input 2 3 div_num=input() 4 5 # try block 6 try: 7 8 user_num=input() 11 12 # converting the input to int user_num= int(user_num) 9 div_num= int(div_num) 10 quotient = user_num // div_num print (quotient) 13 except ZeroDivisionError: 14 main.py print('Zero Division Exception: integer division or modulo by zero') 15 except valueError: 16 print('Input Exception: invalid literal for int() with base 10:', '{}'.format(user_num))
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage