Question: ENED 1 1 2 0 - ACTIVITY PYTHON 5 : LISTS TASK 1 ( OF 4 ) OBJECTIVES: The student will review repetition structures and
ENED ACTIVITY
PYTHON : LISTS
TASK OF
OBJECTIVES: The student will review repetition structures and practice creating lists and indexing into a list.
TIMEKEEPER: This task should take approximately minutes. The time estimate is only a guideline some teams may use less time, while others may use more
Develop a Python program that:
Imports the random library using the command: import random.
Prompts the user for the number of times, to roll two dice should be a positive integer
Checks to make sure is positive and continues to prompt until is greater than zero. Note: you don't have to check if is an integer because the int command with throw an error if user enters a decimal number.
Has a loop that rolls two dice times and stores the sum of the two dice in a list. Use a command such as: Dicel random. randint to simulate a dice roll.
Has a second loop that goes through the list and counts the number of times the sum of the two dice is Note: it is certainly possible to do this count within the first loop; however, creating the second loop will allow you to practice indexing into a list.
Outputs both the list and the count.
Test your program using a relatively small number of rolls, Results will vary since you are using a random function to generate the dice rolls, but you can look at your list and see if the count of sevens is correct.
Save your program as ACT PythonpUCusername.py
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
