Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE 1 3 2 1 L: Programming and Problem Solving I Lab Assignment 6 1 0 0 points Lists What students will learn: 1 )

CSE 1321L: Programming and Problem Solving I Lab
Assignment 6100 points
Lists
What students will learn:
1) Declaring lists
2) Performing common operations on lists
Overview: Lists are an incredibly powerful thing in computing. Almost every audio file, video file,
and image youve ever seen on a computer is stored in a list-like structure. A list is simply a
data structure that holds a lot of values. For example, they could hold 50 integers, 100
Booleans, or a million floats.
Assignment 6A: Keeping Score. Now that we know about lists, we can keep track of when
events occur during our program. To prove this, lets create a game of Rock-Paper-Scissors.
For those not familiar with this game, the basic premise is that each player says Rock-Paper-
Scissors! and then makes their hand into the shape of one of the three objects. Winners are
determined based on the following rules:
Rock beats Scissors
Scissors beats Paper
Paper beats Rock
At the start of the program, it will ask the player how many rounds of Rock-Paper-
Scissors they want to play. After this, the game will loop for that many number of times.
Each loop, it will ask the player what item they want to use Rock, Paper, or Scissors.
The computer will randomly generate its own item, and a winner will be determined.
The game will then save the result as an element of a list, and the next round will begin.
Once all the rounds have been played, the program will say Game Over and display a
list of who won each round, in order.
Hints: While the random functions weve discussed thus far cant generate words, we
can associate numbers with them instead. For example, we might treat the computer
randomly generating 0 as if it threw Rock. We could then use that number to access a
predefined string list with Rock,Paper, and Scissors stored inside it.
Sample Output #1:
How many games do you want to play?: 3
Round 1: What do you want to throw?: Rock
Computer threw SCISSORS!
Round 2: What do you want to throw?: Paper
Computer threw PAPER!
Round 3: What do you want to throw?: Rock
Computer threw PAPER!
Game Over...
Heres the recap:
Player won Round 1 with Rock
Tied on Round 2 with Paper
Computer won Round 3 with Paper
Sample Output #2:
How many games do you want to play?: 2
Round 1: What do you want to throw?: Scissors
Computer threw ROCK!
Round 2: What do you want to throw?: Paper
Computer threw SCISSORS!
Game Over...
Heres the recap:
Computer won Round 1 with Rock
Computer won Round 2 with Scissors

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

More Books

Students also viewed these Databases questions

Question

Why is naval enforcement of counter-piracy practically difficult?

Answered: 1 week ago

Question

Solve the following 1,4 3 2TT 5x- 1+ (15 x) dx 5X

Answered: 1 week ago