Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7.20 Chapter 7 Homework - Functions This lab requires you to write several functions. Some of your functions will be tested via unit tests and

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

7.20 Chapter 7 Homework - 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. Make sure to provide a descriptive comment for each function. 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 between the low value and high value and return the larger of the two. You should seed the random number generator with the value 10 (use random. seed (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 arguments 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 pairs of dice to roll and a number representing the number of sides on the dice. You should seed the random number generator with the value 10 . This version will roll pairs of dice, but will only count and print rolls where the two dice have different numbers. For instance, two rolls of two 6 same. You should make one call to this function using the arguments 5, 10. You may hard code these values into your main function. main.py Load default template... Latest submission - 3:42 PM EST on 03/04/23 Total score: 4/15 Only show failing tests Download this submission 1:Unit test - is_equal1 1/1 Test is_equal (5,6) returns false. Test feedback 2:Unit test - is_equal2 1/1 Test is_equal (7,7) returns true. Test feedback 3:Unit test - my_random1 0/2 Test my_random (2,18) Test feedback my_random (2,18)) incorrectly returned 13. Have you set the proper seed? 4:Copy of Unit test - my_random 2 i 2/2 Random number generator for 2,2 Test feedback 6:Compare output - roll_no_pairs_dice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions