Mixed Numbers Challenge

Before completing this challenge we need to revise some Maths concepts.

Fraction = numerator / denominator


In Maths a fraction consists of two numbers: a numerator and a denominator.

What is an improper fraction?


An improper fraction is a fraction where the numerator is greater than or equal to the denominator.

For instance:
74, 1210, 213 are all improper fractions.

What is a proper fraction?


A proper fraction is a fraction where the numerator is lower than to the denominator.

For instance:
79, 1221, 34 are all proper fractions.

What is a mixed number?


A mixed number is a number consisting of a whole number and a proper fraction.

For instance:
312, 1310, 2134 are all mixed numbers.

Converting improper fractions into mixed numbers


We can easily convert an improper fraction into a mixed number by calculating the quotient and the remainder from the improper fraction.

Mixed number = Quotient RemainderDenominator

For instance: Let’s convert 114 into a mixed number

Step 1: Quotient (Whole Division): 11 DIV 4 = 2
Step 2: Remainder: 11 MOD 4 = 3

114 = 2 34

Quotient & Remainder in Python?


In Python you can use the // operator to calculate the quotient of a fraction and the % operator to calculate the remainder of a fraction.

For instance:

quotient = 11 // 4
remainder = 11 % 4

Python Challenge #1


Complete the code given below to convert an improper fraction into a mixed number by:

  1. Check that the user has entered a numerator and a denominator for an improper fraction. (The numerator should be greater or equal to the denominator).
  2. Calculate and display the mixed number corresponding to the given fraction.

Python Challenge #2


Create a Python script to convert a mixed number into an improper fraction.
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: 8

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

As you found this challenge interesting...

Follow us on social media!