Answered step by step
Verified Expert Solution
Link Copied!

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

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
image text in transcribed

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions