Question: There are a number of ways to implement the functionality described in this problem and it can be done using only the language features described
There are a number of ways to implement the functionality described in this problem and it can be done using only the language features described in lecture. Figuring out the implementation is a large part of the challenge. Another part will be figuring out how to give Gradescope exactly what it wants.
Often times two seemingly equivalent calculations will arrive at slightly different floating point results due to rounding errors inherent in the representation of these numbers in the computer.
printWeight on moon:",
Weight on moon:
printWeight on moon:",
Weight on moon:
To circumvent this issue some sort of approximate equality is almost always used when comparing two floating point numbers. In this problem you will explore an implementation of approximate equality.
Two numbers are the same to decimal places if the absolute value of their difference is less than They are the same to decimal places if the absolute value of their difference is less than and so on
You will write a program that takes two floating point numbers as input. If the numbers are identical then it will print "Those numbers are identical" as illustrated below.
Enter a number:
Enter a number:
Those numbers are identical
If the numbers are the same to decimal places, the program will print "Those numbers are the same to N decimal places" where N is a number from through as illustrated below.
Enter a number:
Enter a number:
Those numbers are the same to decimal places
If the numbers are the same to more than decimal places the program will print "Those numbers are nearly identical" as illustrated below.
Enter a number:
Enter a number:
Those numbers are nearly identical
If none of the previous categories apply because the numbers are the same to or fewer decimal places, the program will print "Those numbers are different" as illustrated below.
Enter a number:
Enter a number:
Those numbers are different
Save this and submit your completed program to gradescope as approx.py
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
