Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview You will write a program that will use a while loop to prompt a user for first _ num and second _ num, divide

Overview
You will write a program that will use a while loop to prompt a user for first_num and second_num, divide first_num by second_num and store the result in a variable called answer, and then print it out cleanly. Your program should handle the divide by zero error (and no other errors) and should make use of a try-execept-else block. It should continue until the user enters a 'q'.
Expected Output
Example 1
What is the first number? (or type q to quit)5
What is the second number? 90
5/90 is 0.05555555555555555
What is the first number? (or type q to quit)3
What is the second number? 0
You cannot divide by zero
What is the first number? (or type q to quit)55
What is the second number? 10
55/10 is 5.5
What is the first number? (or type q to quit) q
The program is over
Specifications
You should submit a single file called M8A3.py
It should follow the submission standards outlined here: Submission Standards
Your program must use a while-loop to collect user input until the user enters 'q'.
Your program must store the user input in variables called first_num and second_num and must store the calculation in a variable named answer.
Your program must catch the error of dividing by zero only using a try-excecpt-else block
Tips and Tricks
Besides the error handling casting is key to this one. Make sure you are converting variables to the type you need when you need it.
Hard-Coded
Nothing is hard-coded for this file

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

More Books

Students also viewed these Databases questions