Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

Identify the two steps in glycolysis in which ATP is produced.

Answered: 1 week ago

Question

What is the relation of physical mathematics with examples?

Answered: 1 week ago

Question

What are oxidation and reduction reactions? Explain with examples

Answered: 1 week ago

Question

1 The difference between a command system and a market system.

Answered: 1 week ago

Question

4 How the market system adjusts to change and promotes progress.

Answered: 1 week ago