![jazmaine1217](/avatars/19579.jpg)
jazmaine1217
07.03.2020 •
Computers and Technology
Write a function that plays the popular scissor-rock-paper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) Function prototype: void gameOfScissorRockPaper(int) The function randomly generates a number 0, 1, or 2 representing SCISSOR, ROCK, and PAPER. It prompts the user to enter a number 0, 1, or 2 and displays messages indicating the choices from the user and computer, whether the user or the computer wins, loses, or draws. If the user enters an invalid choice, prompt an error message, and ask to re-enter the choice. The function takes one int argument specified how many FIRST wins from the computer or the user to win the game. It will let the user continuously play until either the user or the computer wins. Use enum to define Inputs values as below to check the user's input in your program,
Solved
Show answers
More tips
- H Health and Medicine Liver Cleansing - Rejuvenation for the Body?...
- L Leisure and Entertainment Scrapbooking: What is it and Why is it Becoming More Popular?...
- H Horoscopes, Magic, Divination How to Cast a Love Spell on a Guy? Guide for Guys...
- F Family and Home How to Sew Curtain Tapes: Best Tips from Professionals...
- S Style and Beauty How are artificial nails removed?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- F Food and Cooking The Disease That Haunted Abraham Lincoln...
- C Computers and Internet How to Get Rid of Windows Genuine Check?...
- H Health and Medicine How to perform artificial respiration?...
- S Style and Beauty Tricks and Tips: How to Get Rid of Freckles...
Answers on questions: Computers and Technology
- C Computers and Technology Keyboard question: how do i make the congruent to symbol on this keyboard?...
- C Computers and Technology According to the article, what is one example of a modern device that first took form in a book or story? A. portable MP3 players B. outer-space satellites C. electric automobiles...
- C Computers and Technology An array of Strings, names, has been declared and initialized. Write the statements needed to determine whether any of the array elements are null or refer to the empty String....
- C Computers and Technology Given a structural design calling for 1-inch rebar with 2 inches of cover and a spacing of 2 inches center-to-center in a 9-inch thick wall section and the concrete is to...
- C Computers and Technology Write an x86_64 Assembly program that sorts a programmer-defined array. The size of the array and the address of the array should be passed to the called sort function via...
- C Computers and Technology Exploratory data analysis, also called data mining, is used regularly in healthcare to find trends and patterns in the various data sources available and is primarily performed...
- C Computers and Technology Create a spreadsheet that allows the user to easily input the boundary temperatures for 4 edges and a center portion of a grid of at least 20X20. The nonspecified interior...
- C Chemistry An unstable nucleus a. increases its nuclear mass by fission b. increases its half-life c. emits energy when it decays d. expels all of its protons...
- E English Which description best fits otto frank? a. distant, reserved, cold b. quiet, innocent, withdrawn c. boisterous, brash, obnoxious d. warm, generous, pleasant...
- M Mathematics What should i type here? will give brainliest and 25 points asap!...
Ответ:
Python Code:
# import random module
import random
# Print multiline instruction
# performstring concatenation of string
print("Winning Rules of the Rock paper scissor game as follows: \n"
+"Rock vs paper->paper wins \n"
+ "Rock vs scissor->Rock wins \n"
+"paper vs scissor->scissor wins \n")
while True:
print("Enter choice \n 1. Rock \n 2. paper \n 3. scissor \n")
# take the input from user
choice = int(input("User turn: "))
# OR is the short-circuit operator
# if any one of the condition is true
# then it return True value
# looping until user enter invalid input
while choice > 3 or choice < 1:
choice = int(input("enter valid input: "))
# initialize value of choice_name variable
# corresponding to the choice value
if choice == 1:
choice_name = 'Rock'
elif choice == 2:
choice_name = 'paper'
else:
choice_name = 'scissor'
# print user choice
print("user choice is: " + choice_name)
print("\nNow its computer turn")
# Computer chooses randomly any number
# among 1 , 2 and 3. Using randint method
# of random module
comp_choice = random.randint(1, 3)
# looping until comp_choice value
# is equal to the choice value
while comp_choice == choice:
comp_choice = random.randint(1, 3)
# initialize value of comp_choice_name
# variable corresponding to the choice value
if comp_choice == 1:
comp_choice_name = 'Rock'
elif comp_choice == 2:
comp_choice_name = 'paper'
else:
comp_choice_name = 'scissor'
print("Computer choice is: " + comp_choice_name)
print(choice_name + " V/s " + comp_choice_name)
# condition for winning
if((choice == 1 and comp_choice == 2) or
(choice == 2 and comp_choice ==1 )):
print("paper wins => ", end = "")
result = "paper"
elif((choice == 1 and comp_choice == 3) or
(choice == 3 and comp_choice == 1)):
print("Rock wins =>", end = "")
result = "Rock"
else:
print("scissor wins =>", end = "")
result = "scissor"
# Printing either user or computer wins
if result == choice_name:
print("<== User wins ==>")
else:
print("<== Computer wins ==>")
print("Do you want to play again? (Y/N)")
ans = input()
# if user input n or N then condition is True
if ans == 'n' or ans == 'N':
break
# after coming out of the while loop
# we print thanks for playing
print("\nThanks for playing")
Explanation:
Ответ:
The 2nd one is a diode.
The 3rd is a resistor.
The 4th is an optic switch, which can be a LED switch.