Proportions and cross products

A proportion is simply a statement that two ratios are equal. The following are examples of proportions:

  • 1/4 = 25/100
  • 8/24 = 1/3
  • 40/60 = 2/3

Proportions are often use in Maths to simplify a fraction or to represent a fraction as a percentage.
percentage

In order two find out if two fractions are equal, we can use one of the following three methods:

  • Calculate and compare their decimal values: e.g. 25/100 = 0.25 and 1/4 = 0.25 so 25/100 = 1/4
  • Simplify both fractions: e.g. 75/100 = 3/4 and 18/24 = 3/4 so 75/100 = 18/24
  • Compare cross products: e.g. 3 x 6 = 2 x 9 so 2/6 = 3/9

Cross Products


You can compare two fractions to find out if they are equal or not if their cross products are equal:
cross-products

Python Challenge


Your aim is to write a Python program that will check if two fractions are equal or not using the cross products approach. The program will take 4 inputs: the numerator and denominator of both fractions.
It will then compare the cross products to decide and output if the two fractions are equal or not.

You will not to complete the following code:

Test Plan


Complete the following tests to check that your code is working as expected:

Test # Input Values Expected Output Actual Output
#1 Fraction #1: 4/6
Fraction #2: 20/30
These fractions are equal.
#2 Fraction #1: 4/6
Fraction #2: 20/40
These fractions are not equal.
#3 Fraction #1: 75/100
Fraction #2: 3/4
These fractions are equal.
#4 Fraction #1: 1/3
Fraction #2: 30/100
These fractions are not equal.
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 15

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!