Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Read through the code snippet below, figure out what would be the outputs if the following inputs are provided and explain why ( put your

Read through the code snippet below, figure out what would be the outputs if the following inputs are provided and explain why (put your explanation in the markdown cell below):
-`32//0`
-`21*4`
-`34+3`
```python
while True:
exp_str = input("Input an arithmetic expression (separate different parts with spaces)
>>>")
output = None
try:
str_ls = exp_str.split()
operand2= float(str_ls[2])
operand1= float(str_ls[0])
if str_ls[1]=='*':
output = operand1* operand2
elif str_ls[1]=='/':
output = operand1/ operand2
elif str_ls[1]=='+':
output = operand1+ operand2
elif str_ls[1]=='-':
output = operand1- operand2
except IndexError:
print("Failed to provide the right number of inputs. Remember to separate different parts with spaces!")
except ValueError:
print("Failed to provide a valid numeric input.")
except Exception as e:
print(f"Other erros: {e}")
else:
if not output:
print("Undefined operation!")
else:
print(f"{''.join(exp_str.split())}={output}")
break
```

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

How competitive is the external environment of your organization?

Answered: 1 week ago

Question

What other organizations compete on this issue?

Answered: 1 week ago

Question

What significant opposition exists?

Answered: 1 week ago