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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY