Describe the logic required in the algorithmic solution

Assignment Help Computer Engineering
Reference no: EM133548888

Question: Describe the logic required in the algorithmic solution regarding the control structures used (sequence, selection and iteration). Provide detailed explanations.

The purpose is to convey that you have used the most efficient control structure(s) in the solution.

def correct_choice(player_name):

while True:

choice = input(f"{player_name}, please choose rock, paper, or scissors: ").lower()

if choice in choices:

return choice

else:

print(f"wrong choice. {player_name}, please choose rock, paper, or scissors.")

print("Welcome to Rock Paper Scissors!")

player1 = input("Enter Player 1's name: ").capitalize()

player2 = input("Enter Player 2's name: ").capitalize()

rounds = int(input("Enter how many rounds you want to play: "))

score1 = 0

score2 = 0

choices = ["rock", "paper", "scissors"]

 

print("\nLet's start!")

 

for round_num in range(1, rounds + 1):

print(f"\nRound {round_num}:")

 

choice1 = correct_choice(player1)

choice2 = correct_choice(player2)

 

print(f"{player1} chose {choice1}")

print(f"{player2} chose {choice2}")

 

if choice1 == choice2:

print("It's a tie!")

elif (choice1 == "rock" and choice2 == "scissors") or \

(choice1 == "paper" and choice2 == "rock") or \

(choice1 == "scissors" and choice2 == "paper"):

print(f"{player1} wins this round!")

score1 += 1

else:

print(f"{player2} wins this round!")

score2 += 1

 

print("\nGame Over!")

print(f"Final Score: {player1}: {score1} {player2}: {score2}")

if score1 > score2:

print(f"{player1} wins the game!")

elif score2 > score1:

print(f"{player2} wins the game!")

else:

print("The game is a tie!")

 

print(f"\nThank you, {player1} and {player2}, for playing!")

Reference no: EM133548888

Questions Cloud

Cognitive-behavioural approach : How might you conceptualize this family, using a cognitive-behavioural approach?
Explain how your view of leadership has influenced how : what you believe about yourself, explain how the highest Total Score really does or does not reflect who you think you are? Explain how your view of leadership
Discuss united states v. taylor with regard to headnote 4 : When Kelly Shepardizes or KeyCites her case, can she determine if later cases discuss United States v. Taylor with regard to headnote 4?
Find the final matrix and the solution of the system : row cell x minus 2 y equals 14 end cell end table close by Gaussian elimination. Find the final matrix and the solution of the system
Describe the logic required in the algorithmic solution : Describe the logic required in the algorithmic solution regarding the control structures used (sequence, selection and iteration). Provide detailed explanations
Identify community role of community rehabilitation : Identify the community role of community rehabilitation. What population does a community rehabilitation worker work with?
What rights other than equality are potentially violated : What right could Article 14 ride on? What rights other than equality are potentially violated here?
What is included in the page header of all papers : What is included in the page header of all papers (student and professional)? a. running head, left-aligned b. running head, right-aligned c. page number
Discuss possible ethics problems : Discuss possible ethics problems if the researcher utilized the names of offenders listed on this site to search for information on their education, occupation

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd