Question: Farkle Utility Functions Let's start by creating a module named farkle_utils which contains several helper functions needed to implements the full program. Inside this module

 Farkle Utility Functions Let's start by creating a module named farkle_utils

Farkle Utility Functions Let's start by creating a module named farkle_utils which contains several helper functions needed to implements the full program. Inside this module import the module random. For full marks, all the following functions must be part of this module. Be carefull, functions that take lists as input should not modify them. To prevent this from happening you can create additional lists inside the function which are copies of the inputs and work with those instead. single_dice_roll: simulates the roll of one 6-sided dice. The function takes no inputs, and returns an integer between 1 and 6 (both included). Please use randint to do so. For example: >>> randon.seed (1800) >>> single_dice roll) 4 >>> randon.seed (3) >>> single_dice_roll) 2 >>> single_dice_roll) 5 dice_rolls: given a positive integer n as input, it returns a list containing the numbers representing n independent G-sided dice rolls. For example: >>> randon.seed (1) >>> dice_rolls(6) [2, 5, 1, 3, 1, 4) >>> random.seed (3) >>> dice_rolls(2) [2, 5] contains repetitions: given a list of integers, an integer n, and a second positive integer m, the function returns True if n appears in the list at least a times, False otherwise. For example: >>> conta ins_repetitions([1, 2, 1), 1, 2) True >>> contains_repetitions [1, 2, 1, 1), 2, 5) False >>> contains_repetitions([1, 2, 1, 1, 2, 1), 1, 3) True pick_randon_element: given a list of integers, it returns a random element from the list. If the list is empty, the function should return None

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!