Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions