Exercise 5.2 (calculator.py). Write a small calculator that can compute arcsin, arccos, arctan and square root of a number. Use math.sqrt(), math.asin(), math.acos(), and math.atan (). Remember to import math. Make sure to check for each function that the input is valid. Function Valid Input Should be math.sqrt() non-negative math.asin() between -1 and 1 math.acos() between -1 and 1 math.atan () any number 1 $ python3 calculator.py 2 Enter a number to use: 16 3 Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): s 4 The square root of the input is 5 4.0 6 $ python3 calculator.py 7 Enter a number to use: 1.1 s Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): a Input should be between -1 and 1 9 10 $ python3 calculator.py 11 Enter a number to use: 0.5 12 Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): a 13 The arcsine of the input is 14 0.5235987755982989 15 $ python3 calculator.py 16 Enter a number to use: 1000 17 Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): t 18 The arctangent of the input is 19 1.5697963271282298
Exercise 5.2 (calculator.py). Write a small calculator that can compute arcsin, arccos, arctan and square root of a number. Use math.sqrt(), math.asin(), math.acos(), and math.atan (). Remember to import math. Make sure to check for each function that the input is valid. Function Valid Input Should be math.sqrt() non-negative math.asin() between -1 and 1 math.acos() between -1 and 1 math.atan () any number 1 $ python3 calculator.py 2 Enter a number to use: 16 3 Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): s 4 The square root of the input is 5 4.0 6 $ python3 calculator.py 7 Enter a number to use: 1.1 s Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): a Input should be between -1 and 1 9 10 $ python3 calculator.py 11 Enter a number to use: 0.5 12 Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): a 13 The arcsine of the input is 14 0.5235987755982989 15 $ python3 calculator.py 16 Enter a number to use: 1000 17 Which operation? sqrt (s), arcsin (a), arccos (c), arctan (t): t 18 The arctangent of the input is 19 1.5697963271282298
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr