Question: Write a function factors( n ) which accepts a number n and returns a list containing all of the factors of that number. (This is

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 codedon't just google 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 ).

I NEED TO FILL IN THE BLANKS IN TEH STARTER CODE IS MY SPECFIC QUESTION:

def factors( n ): pass

def 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

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 Databases Questions!