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.
```
>>> print("Weight on moon:", 100/6)
Weight on moon: 16.666666666666668
`` print("Weight on moon:", 100*(1/6))
Weight on moon: 16.666666666666664
```
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 2 decimal places if the absolute value of their difference is less than 0.01. They are the same to 4 decimal places if the absolute value of their difference is less than 0.0001, 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: 3.14
Enter a number: 3.14
Those numbers are identical
If the numbers are the same to 2-9 decimal places, the program will print "Those numbers are the same to N decimal places" (where N is a number from 2 through 9) as illustrated below.
Enter a number:3.1415926
Enter a number: 3.1415928
Those numbers are the same to 6 decimal places
If the numbers are the same to more than 9 decimal places the program will print "Those numbers are nearly identical" as illustrated below.
Enter a number: 16.666666666666668
Enter a number: 16.666666666666664
Those numbers are nearly identical
If none of the previous categories apply because the numbers are the same to 1 or fewer decimal places, the program will print "Those numbers are different" as illustrated below.
Enter a number: 3.14
Enter a number:3
Those numbers are different
Save this and submit your completed program to gradescope as approx.py
There are a number of ways to implement the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!