Answered step by step
Verified Expert Solution
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 L: Programming and Problem Solving I Lab
Assignment points
Lists
What students will learn:
Declaring lists
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 listlike structure. A list is simply a
data structure that holds a lot of values. For example, they could hold integers,
Booleans, or a million floats.
Assignment A: 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 RockPaperScissors.
For those not familiar with this game, the basic premise is that each player says RockPaper
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 RockPaper
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 as if it threw Rock. We could then use that number to access a
predefined string list with RockPaper and Scissors stored inside it
Sample Output #:
How many games do you want to play?:
Round : What do you want to throw?: Rock
Computer threw SCISSORS!
Round : What do you want to throw?: Paper
Computer threw PAPER!
Round : What do you want to throw?: Rock
Computer threw PAPER!
Game Over...
Heres the recap:
Player won Round with Rock
Tied on Round with Paper
Computer won Round with Paper
Sample Output #:
How many games do you want to play?:
Round : What do you want to throw?: Scissors
Computer threw ROCK!
Round : What do you want to throw?: Paper
Computer threw SCISSORS!
Game Over...
Heres the recap:
Computer won Round with Rock
Computer won Round with Scissors
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