Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with the code below and I have attempted to add the correct code but I'm getting the incorrect result. Per the

I need some help with the code below and I have attempted to add the correct code but I'm getting the incorrect result. Per the "mystery_value = 5" the code I wrote printed: 1.0

25

and the expected value should be 1.0.

#Write program that divides mystery_value by mystery_value

#and prints the result. If that operation results in an

#error, divide mystery_value by (mystery_value + 5) and then

#print the result. If that still fails, multiply mystery_value

#by 5 and print the result. You may assume one of those three

#things will work.

#

#You may not use any conditionals.

#

#Hint: You're going to want to test one try/except structure

#inside another! Think carefully about whether the second

#one should go inside the try block or the except block.

#Add your code here!

try:

print(mystery_value / mystery_value)

except:

print(mystery_value (mystery_value + 5))

else:

print(mystery_value * 5)

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Programming questions