Question: ENED 1 1 2 0 - ACTIVITY PYTHON 5 : LISTS TASK 1 ( OF 4 ) OBJECTIVES: The student will review repetition structures and

ENED1120- ACTIVITY
PYTHON 5: LISTS
TASK 1(OF 4)
OBJECTIVES: The student will review repetition structures and practice creating lists and indexing into a list.
TIMEKEEPER: This task should take approximately 20 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, N, to roll two dice (should be a positive integer).
Checks to make sure N is positive and continues to prompt until N is greater than zero. Note: you don't have to check if N is an integer because the int command with throw an error if user enters a decimal number.
Has a loop that rolls two dice N times and stores the sum of the two dice in a list. Use a command such as: Dicel = random. randint (1,6) 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 7. 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, N. 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 Python_5p1_UCusername.py
 ENED1120- ACTIVITY PYTHON 5: LISTS TASK 1(OF 4) OBJECTIVES: The student

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!