Task 1: Rock, Paper, Scissors (Topics: Variables, user-input, flow-control, function) Task 1 implements the "rock, paper, scissors" game. This is a two-player game, where Scissors beats poper each player simultaneously selects from one of three options: rock, paper, scissors. The game is typically played with hand gestures and has the following rules: Rock wins against scissors, loses to paper, ties with rock. Paper wins against rock, loses to scissors, ties with paper. Scissors win against paper, lose to rock, tie with scissors. Image credit: Enzoklop (CC) In a real game, both players would make their selection simultaneously. In our version, the user will select first, and then the computer opponent named "HAL" will make a random selection. Require function In addition to the task1() function, you need to implement the following function: printOutcome(params: userSelection, computerSelection) -> no return The parameters are the user's and computer's selection. The function prints the outcomes depending on the selections (1) "You win!"; (2) "HAL wins!"; (3) "A tie!" You decide what data type the parameters should be (e.g., integers representing the selection or strings representing "rock", "paper", "scissors"). Just ensure your function prints the correct outcome. Task 1 should behave as follows: (1) Print "Rock, Paper, Scissors!" (2) Print "Make your selection..." (3) Get input from user – 1 (rock), 2 (paper), 3 (scissors). (4) If the input is not 1, 2, or 3, print "Invalid selection. Try again." and ask the user for input again. (5) Randomly select HAL's choice – rock, paper, scissors. (6) Print out the user's selection and HAL's selection. (7) Pass the user's and HAL's selections to the function printOutcome() to print the outcome of the game. (8) Ask the user if they want to play again (Y). If the input is 'Y' or 'y', go back to (2). Example of task 1 running (user input in red) – see video link for more examples. ---- Task1: Rock, Paper, Scissors Rock, Paper, Scissors! Make your selection. (1) rock, (2) paper, (3) scissors? 1 You: rock HAL: rock A tie! Play again (Y/N)? y Make your selection. . . (1) rock, (2) paper, (3) scissors? 2 You: paper HAL: scissors HAL wins! Play again (Y/N)? y Make your selection. . . (1) rock, (2) paper, (3) scissors? 44 Invalid selection. Try again. Make your selection. (1) rock, (2) paper, (3) scissors? 3 You can assume the input will be an integer. Check if it is 1, 2 or 3. If not, inform user of invalid selection as shown. You: scissors HAL: paper You win! Play again (Y/N)? n Jaded Rock

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In Python please

Task 1: Rock, Paper, Scissors (Topics: Variables, user-input, flow-control, function)
Task 1 implements the "rock, paper, scissors" game. This is a two-player game, where
each player simultaneously selects from one of three options: rock, paper, scissors.
Scissors
beats paper
The game is typically played with hand gestures and has the following rules:
Rock wins against scissors, loses to paper, ties with rock.
Paper wins against rock, loses to scissors, ties with paper.
Scissors win against paper, lose to rock, tie with scissors.
In a real game, both players would make their selection simultaneously.
In our version, the user will select first, and then the computer opponent named "HAL" will make a random selection.
Image credit: Enzoklap (CC)
Require function
In addition to the task1() function, you need to implement the following function:
printOutcome (params: userSelection, computerSelection) -> no return
The parameters are the user's and computer's selection. The function prints the outcomes depending on the selections:
(1) "You win!"; (2) "HAL wins!"; (3) "A tie!"
You decide what data type the parameters should be (e.g., integers representing the selection or strings representing
"rock", "paper", "scissors"). Just ensure your function prints the correct outcome.
Task 1 should behave as follows:
(1) Print "Rock, Paper, Scissors!"
(2) Print "Make your selection..."
(3) Get input from user – 1 (rock), 2 (paper), 3 (scissors).
(4) If the input is not 1, 2, or 3, print "Invalid selection. Try again." and ask the user for input again.
(5) Randomly select HAL's choice – rock, paper, scissors.
(6) Print out the user's selection and HAL's selection.
(7) Pass the user's and HAL's selections to the function printOutcome() to print the outcome of the game.
(8) Ask the user if they want to play again (Y). If the input is 'Y' or 'y', go back to (2).
Example of task 1 running (user input in red) – see video link for more examples.
Task1: Rock, Paper, Scissors
-------
Rock, Paper, Scissors!
Make your selection. ..
(1) rock, (2) paper, (3) scissors? 1
You: rock
HAL: rock
A tie!
Play again (Y/N)? y
Make your selection.
(1) rock, (2) paper, (3) scissors? 2
You: paper
HAL: scissors
HAL wins!
Play again (Y/N)? y
Make your selection.
(1) rock, (2) paper, (3) scissors? 44
Invalid selection. Try again.
Make your selection.
(1) rock, (2) paper, (3) scissors? 3
You: scissors
You can assume the input will be an integer.
Check if it is 1, 2 or 3. If not, inform user of
invalid selection as shown.
..
HAL: раper
You win!
Play again (Y/N)? n
Paper
Rock
bets socsone
Transcribed Image Text:Task 1: Rock, Paper, Scissors (Topics: Variables, user-input, flow-control, function) Task 1 implements the "rock, paper, scissors" game. This is a two-player game, where each player simultaneously selects from one of three options: rock, paper, scissors. Scissors beats paper The game is typically played with hand gestures and has the following rules: Rock wins against scissors, loses to paper, ties with rock. Paper wins against rock, loses to scissors, ties with paper. Scissors win against paper, lose to rock, tie with scissors. In a real game, both players would make their selection simultaneously. In our version, the user will select first, and then the computer opponent named "HAL" will make a random selection. Image credit: Enzoklap (CC) Require function In addition to the task1() function, you need to implement the following function: printOutcome (params: userSelection, computerSelection) -> no return The parameters are the user's and computer's selection. The function prints the outcomes depending on the selections: (1) "You win!"; (2) "HAL wins!"; (3) "A tie!" You decide what data type the parameters should be (e.g., integers representing the selection or strings representing "rock", "paper", "scissors"). Just ensure your function prints the correct outcome. Task 1 should behave as follows: (1) Print "Rock, Paper, Scissors!" (2) Print "Make your selection..." (3) Get input from user – 1 (rock), 2 (paper), 3 (scissors). (4) If the input is not 1, 2, or 3, print "Invalid selection. Try again." and ask the user for input again. (5) Randomly select HAL's choice – rock, paper, scissors. (6) Print out the user's selection and HAL's selection. (7) Pass the user's and HAL's selections to the function printOutcome() to print the outcome of the game. (8) Ask the user if they want to play again (Y). If the input is 'Y' or 'y', go back to (2). Example of task 1 running (user input in red) – see video link for more examples. Task1: Rock, Paper, Scissors ------- Rock, Paper, Scissors! Make your selection. .. (1) rock, (2) paper, (3) scissors? 1 You: rock HAL: rock A tie! Play again (Y/N)? y Make your selection. (1) rock, (2) paper, (3) scissors? 2 You: paper HAL: scissors HAL wins! Play again (Y/N)? y Make your selection. (1) rock, (2) paper, (3) scissors? 44 Invalid selection. Try again. Make your selection. (1) rock, (2) paper, (3) scissors? 3 You: scissors You can assume the input will be an integer. Check if it is 1, 2 or 3. If not, inform user of invalid selection as shown. .. HAL: раper You win! Play again (Y/N)? n Paper Rock bets socsone
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education