View the step-by-step solution to:

Question

Part I Instructions:



You are going to work on the

following:


A simple calculator to accept two numbers and print the addition, subtraction, multiplication and division of the two numbers.


You are required to store each input number in a separate variable.


Hints

      

     1) You should also store each calculation in a variable

     2) You will get an error if you divide by zero, you will address this problem next assignment

3) Make Try again? Yes / No condition


Sample output


This is my first programming assignment

Enter your First number ---> 25

Enter your Second number ---> 14


The Result of 25+14=39.0

The Result of 25-14=11.0

The Result of 25*14=350.0

The Result of 25/14=1.78571428571

 

Thanks for using our calculator!

 


 

Part II Instructions:  


 

Enhance the prior task by doing the following:


1) Limit the input range from -100 to 100 for each input number

2) Prevent dividing by zero (Do not use try-except)

3) Instead of hard coding values from -100 to 100, let the user enter the range

4) Make Try again? Yes / No condition



Here is what I have so far.....


print('This is my first programming assignment')


a = int(input('Enter your First number ---> '))

b = int(input('Enter your Second number ---> '))


print('The Result of',a,'+',b,'=',(a+b))

print('The Result of',a,'-',b,'=',(a-b))

print('The Result of',a,'*',b,'=',(a*b))

print('The Result of',a,'/',b,'=',(a/b))


---------------------------------------------------------------------------------------------------------------


minRange = int(input('Enter your Lower range ---> '))

maxRange = int(input('Enter your Higher range ---> '))

if(maxRange>minRange):

  a = int(input('Enter your First number ---> '))

  b = int(input('Enter your Second number ---> '))


  print('The Result of',a,'+',b,'=',(a+b))

  print('The Result of',a,'-',b,'=',(a-b))

  print('The Result of',a,'*',b,'=',(a*b))

  if(b==0):

    print('The Result of',a,'/',b,'= You cannot divide by Zero')

  else:

    print('The Result of',a,'/',b,'=',(a/b))

else:

  print('Please check the numbers and try again')


print('Thanks for using our calculator')

Top Answer

Please find the answer below. Let me know if you have any doubt. print ( 'This is my first programming assignment' ) minRange... View the full answer

1.JPG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question