Question: python 7.31 Homework 5 - Functions This lab requires you to write several functions. Some of your functions will be tested via unit tests and

python

python 7.31 Homework 5 - Functions This lab requires you to write

7.31 Homework 5 - Functions This lab requires you to write several functions. Some of your functions will be tested via unit tests and some will be tested via output comparison. You should create a main() function to call some of your functions as described below. 1. Write a function called is equal that takes two numbers and returns True if the numbers are equal and False if they are not equal. This function will be tested using unit tests and requires no input and does not need to be called from the main function. 2. Write a function called my_random that takes two numbers, a low value and a high value. The function should generate two random numbers and return the larger of the two. You should seed the random number generator with the value 10. This function will be tested using unit tests and requires no input and does not need to be called from the main() function. 3. Write a function called roll_dice which takes, in order, a number representing the number of dice and a number representing the number of sides on the dice. The function should print a dice roll with a value between 1 and the number of sides on the die for each of the number of dice. You should seed the random number generator with the value 10. You should make two successive calls to this function using the values 4, 8 and 5, 10. You may hard code these values into your main function. 4. Write a function called roll_no_pair_dice which takes, in order, a number representing the number of dice and a number representing the number of sides on the dice. You should seed the random number generator with the value 10. This version of rolling the dice will only print rolls where the two die have different numbers. For instance, two rolls of two 6-sided dice could result in: 1 3 4 6 But not: 1 1 2 3 You must call your is equal function to test whether the two die are the same. You should make one call to this function using the values 5, 10. You may hard code these values into your main function. LAB ACTIVITY 7.31.1: Homework 5 - Functions 0/150 main.py Load default template... 1 import random 2 # Write your functions here def main(): # call your functions here 15 main 7.31 Homework 5 - Functions This lab requires you to write several functions. Some of your functions will be tested via unit tests and some will be tested via output comparison. You should create a main() function to call some of your functions as described below. 1. Write a function called is equal that takes two numbers and returns True if the numbers are equal and False if they are not equal. This function will be tested using unit tests and requires no input and does not need to be called from the main function. 2. Write a function called my_random that takes two numbers, a low value and a high value. The function should generate two random numbers and return the larger of the two. You should seed the random number generator with the value 10. This function will be tested using unit tests and requires no input and does not need to be called from the main() function. 3. Write a function called roll_dice which takes, in order, a number representing the number of dice and a number representing the number of sides on the dice. The function should print a dice roll with a value between 1 and the number of sides on the die for each of the number of dice. You should seed the random number generator with the value 10. You should make two successive calls to this function using the values 4, 8 and 5, 10. You may hard code these values into your main function. 4. Write a function called roll_no_pair_dice which takes, in order, a number representing the number of dice and a number representing the number of sides on the dice. You should seed the random number generator with the value 10. This version of rolling the dice will only print rolls where the two die have different numbers. For instance, two rolls of two 6-sided dice could result in: 1 3 4 6 But not: 1 1 2 3 You must call your is equal function to test whether the two die are the same. You should make one call to this function using the values 5, 10. You may hard code these values into your main function. LAB ACTIVITY 7.31.1: Homework 5 - Functions 0/150 main.py Load default template... 1 import random 2 # Write your functions here def main(): # call your functions here 15 main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!