Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Converting a decimal to a fraction Although computers generally represent numbers as decimals, itis often convenient to express values as fractions. If we desire toconvert

Converting a decimal to a fraction

Although computers generally represent numbers as decimals, itis often convenient to express values as fractions. If we desire toconvert a decimal to a fraction, we need to follow a two-stepprocess:

Starting with the number itself, multiply by ten repeatedlyuntil no values remain after the decimal point. This is thenumerator. Keep the multiplier as the denominator.

Simplify the fraction.

For instance, for 0.75:

1) Multiply by ten repeatedly:

0.75×10×10=75

Thus the numerator is 75 and the denominatoris 10×10=100

2)Simplify the fraction:

Find the factors of the numerator and thedenominator.

75?{1,3,5,25,75}

100?{1,2,4,5,10,20,25,50,100}

Find the greatest common factor of eachand divide both by it.

75÷25=3

100÷ 25 =4

0.75?3/4

Can you fill in the ??? in Python. Just the ???def factors( n ):    passdef fraction( n ):    n_str = str( n )    decimal_part = n_str[ n_str.find( '.' )+1: ]    # 1. Multiply by ten repeatedly (to make all of decimal positive).    numer = n * 10 ** ???    denom = ???    # 2. Find factors.    numer_factors = ???    denom_factors = ???    factor = 1    # ??? find greatest common factor of both numerator and denominator    # ??? divide both by GCF before returning them    return ( numer,denom )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Design Operation And Evaluation Of Mobile Communications

Authors: Gavriel Salvendy ,June Wei

1st Edition

3030770249, 978-3030770242

More Books

Students also viewed these Programming questions