Create a python program called code.py. Write a function named divisible() that takes two integer parameters num1 and num2. Your function must print a random integer number x in the range [low…high] (inclusive), where low is the minimum of num1 and num2, and high is the maximum of num1 and num2. Next, if x is even or if x is divisible by 3, your function must return the squared value of x. otherwise, it should return 0. To test your function, ask the user for an integer number value (input validation is not necessary here), use a loop value times to call divisible() function and print the information returned by this function. You can use any two integers (for num1 and num2) of your choice to call the function. Note, you will not use the built-in min()/max() functions. Hint: to select a random integer, use the following. import random and call random.randint(low, high) that returns an int from the given range.
Create a python program called code.py.
Write a function named divisible() that takes two integer parameters num1 and num2. Your function must print a random integer number x in the range [low…high] (inclusive), where low is the minimum of num1 and num2, and high is the maximum of num1 and num2. Next, if x is even or if x is divisible by 3, your function must return the squared value of x. otherwise, it should return 0.
To test your function, ask the user for an integer number value (input validation is not necessary here), use a loop value times to call divisible() function and print the information returned by this function. You can use any two integers (for num1 and num2) of your choice to call the function.
Note, you will not use the built-in min()/max() functions.
Hint: to select a random integer, use the following.
import random and call random.randint(low, high) that returns an int from the given range.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images