Question

write a python program Write a function is_factor(f, n) that passes these tests: test(is_factor(3, 12)) test(not...

write a python program

Write a function is_factor(f, n) that passes these tests:

test(is_factor(3, 12))

test(not is_factor(5, 12))

test(is_factor(7, 14))

test(not is_factor(7, 15))

test(is_factor(1, 15))

test(is_factor(15, 15))

test(not is_factor(25, 15))

An important role of unit tests is that they can also act as unambiguous “specifications”

of what is expected. These test cases answer the question Do we treat 1 and 15 as factors

of 15?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:-


def is_factor(f,n):
if n%f==0:
return "is_factor"
else:
return "is not a factor"


num=10
factor=3

is_factor(factor,num)

OUTPUT:-

cript.pyIPython Shell Out[1] is not a factor Run

Add a comment
Know the answer?
Add Answer to:
write a python program Write a function is_factor(f, n) that passes these tests: test(is_factor(3, 12)) test(not...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a python program that plots a given function and an interpolation polynomial. To test this,...

    programming in python. Write a python program that plots a given function and an interpolation polynomial. To test this, use the following cases: a) )xp(-4r2), tE-1,1]. As data, use equidistant nodes that include the endpoints and the function values in those nodes. The number of nodes should be 5, then 12. Write a python program that plots a given function and an interpolation polynomial. To test this, use the following cases: a) )xp(-4r2), tE-1,1]. As data, use equidistant nodes that...

  • programming in python. Write a python program that plots a given function and an interpolation polynomial....

    programming in python. Write a python program that plots a given function and an interpolation polynomial. To test this, use the following cases: a) )xp(-4r2), tE-1,1]. As data, use equidistant nodes that include the endpoints and the function values in those nodes. The number of nodes should be 5, then 12.

  • Write a Python program that tests the function main and the functions discussed in parts a...

    Write a Python program that tests the function main and the functions discussed in parts a through g. Create the following lists: inStock - 2D list (row size:10, column size:4) alpha - 1D list with 20 elements. beta - 1D list with 20 elements. gamma = [11, 13, 15, 17] delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8] a. Write the definition of the function setZero that initializes any one-dimensional list to 0 (alpha and beta)....

  • In Python 3, write a function that will take an integer which represents a time given...

    In Python 3, write a function that will take an integer which represents a time given in military time (0 – 2359) and return a string that represents the time in a 12-hour format. If an invalid time is given, the function must return the string “Invalid time”. Examples 1200 will return the string “12:00 PM” 2240 will return the string “10:40 PM” 0600 will return the string “06:00 AM” 2400 will return the string “Invalid time” 1160 will return...

  • Write a program in python to find a single root of a function f(x) on an...

    Write a program in python to find a single root of a function f(x) on an interval [a,b] using the bisectional method. Test your program on an equation that you may easily solve analytically.

  • Write a Python function cardinality() that takes in three Python set objects, representing sets of between...

    Write a Python function cardinality() that takes in three Python set objects, representing sets of between 0 and 50 integers, AA, BB, and UU. Your function should return a single non-negative integer value for the cardinality of the set below. AA and BB are subsets (not necessarily proper) of the universal set UU. |P(A¯¯¯¯∩B)||P(A¯∩B)| Note 1: You can copy-paste the code declaring the various visible test cases below. We strongly encourage you to do this to test your code. Note...

  • Write a PYTHON program that tests to see whether a sequence has an AT repeat. For...

    Write a PYTHON program that tests to see whether a sequence has an AT repeat. For this problem, we’ll define a repeat as 3 or more occurrences of AT, i.e. ATATAT…etc. Read in the sequence from a file (in FASTA format) to test your code. You can use the attached “Test.txt” sequence. Return a message to the user whether or not an AT repeat exits in the sequence. Use at least one function. Test.txt : >TestSeq ATGCTTTACGTCTACTGTCGTATGCTTTACGTCTACTGACTGTCGTATGCTTACGTCTACTGTCG TGCTTTACGTCTACTGACTGTCGTATATATATATATATATTGCTTTACGTCTACTGACTGTCGTA

  • Write a python program using function prime_factorization(n) which will compute the product of all the prime...

    Write a python program using function prime_factorization(n) which will compute the product of all the prime factors of a given input n.

  • Python Program 5. Write a Python program in a file named validTime.py. Include a function named...

    Python Program 5. Write a Python program in a file named validTime.py. Include a function named string parameter of the form hh:mm: ss in which these are numeric validTime that takes a values and returns True or False indicating whether or not the time is valid. The number of hours, minutes, and seconds must two digits and use a between 0 and 9). The number of hours must be between 0 and 23, the number of minutes and seconds must...

  • PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that generates two random...

    PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that generates two random integer numbers between 1 and 100. Then, print out the numbers between the two randomly generated ones using a while loop. The output is shown below. Output: a) start:4, end:14 4 5 6 7 8 9 10 11 12 13 14 b) start:15, end:20 15 16 17 18 19 20

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT