Question: Python code for task #1 import sys # Get User input player1 = input('Enter Value for Player 1: ') if (player1 != 'rock' and player1


Python code for task #1
import sys
# Get User input
player1 = input('Enter Value for Player 1: ')
if (player1 != 'rock' and player1 != 'paper' and player1 != 'scissors'):
print('Player1 input incorrect')
sys.exit('Input Error')
player2 = input('Enter Value for Player 2: ')
if (player2 != 'rock' and player2 != 'paper' and player2 != 'scissors'):
print('Player2 input incorrect')
sys.exit('Input Error')
# Game logic.
# Note that the backslash is a line continuation for long expressions
if player1 == player2:
print ('Players Tie')
elif (player1 == 'rock' and player2 == 'scissors') \
or (player1 == 'paper' and player2 == 'rock') \
or (player1 == 'scissors' and player2 == 'paper'):
print('Player 1 Wins')
else:
print('player 2 wins')
Task1 - Rewrite the game logic to do the following. You can use my code as a starter or you can use your own from the last assignment 1. Convert the user input strings to lower case so that you only have to check lower case in your test. Hint: look at the lower() function in Python. 2. Create a loop for each input that does the following: - Check the value of the input - If the value is not correct, alert the user - Give the user a total of three chances to get it right - If they don't get it right in three tries, use sys.exit to exit the code and give them a message that they exceeded their allowable number of tries Task 2 - FizzBuzz Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". Hints: - You can use a for loop with a range to simplify the iteration - Use the modulo division operator (\%) to find the remainder of a division calculation Note: This is actually a common exercise used in job interviews for entry-level programmers
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
