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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started