Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started