subject
Engineering, 21.04.2020 17:45 aa1000220

Converting a decimal to a fraction Although computers generally represent numbers as decimals, it is often convenient to express values as fractions. If we desire to convert a decimal to a fraction, we need to follow a two-step process: Starting with the number itself, multiply by ten repeatedly until no values remain after the decimal point. This is the numerator. Keep the multiplier as the denominator. Simplify the fraction. For instance, for 0.75: Multiply by ten repeatedly: 0.75×10×10=75 Thus the numerator is 75 and the denominator is 10×10=100. Simplify the fraction: Find the factors of the numerator and the denominator. 75→{1,3,5,15,25,75}100→{1,2,4,5,10, 20,25,50,100} Find the greatest common factor of each and divide both by it. 75÷25=3100÷25=4 0.75→34 Write a function factors( n ) which accepts a number n and returns a list containing all of the factors of that number. (This is a common task. Write your own code—don't just it!) Write a function fraction( n ) which accepts a decimal number n and returns a tuple ( numerator, denominator ) of the resulting fraction representation. Your submission should include two functions factors( n ) and fraction( n ).

ansver
Answers: 3

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Heat is added to a piston-cylinder device filled with 2 kg of air to raise its temperature 400 c from an initial temperature of t1 27 cand pressure of pi 1 mpa. the process is isobaric process. find a)-the final pressure p2 b)-the heat transfer to the air.
Answers: 1
question
Engineering, 04.07.2019 03:10
What precautions should you take to prevent injuries when dealing with heavy loads?
Answers: 1
question
Engineering, 04.07.2019 18:10
The temperature of air decreases as it is compressed by an adiabatic compressor. a)- true b)- false
Answers: 2
question
Engineering, 04.07.2019 18:10
The drive force for diffusion is 7 fick's first law can be used to solve the non-steady state diffusion. a)-true b)-false
Answers: 1
You know the right answer?
Converting a decimal to a fraction Although computers generally represent numbers as decimals, it is...
Questions
question
Computers and Technology, 31.07.2019 02:10
question
Computers and Technology, 31.07.2019 02:10
question
Computers and Technology, 31.07.2019 02:10
question
Computers and Technology, 31.07.2019 02:10
Questions on the website: 13722361