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?
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:-
write a python program Write a function is_factor(f, n) that passes these tests: test(is_factor(3, 12)) test(not...
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. 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 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 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 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 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 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 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 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
write a python program that reads from a file, scores.txt, a list of test scores. the program should calculate the average of all the scores, and print to the screen. the program should also have a function, num_passing, that takes as a parameter the list or grades and returns the number of scores that are above 64.