IN PYTHON
The code below does not load/work.
Debug the following code so that it works.
def rps(play1, play2)
'takes choices of player 1 and 2, and returns -1 if player 1 wins, 1 if player 2 wins,or 0 if there is a tie'
if play1 != play2:
return 1
if (play1 == 'P' and play2 != 'R') or (play1 != 'R' and play2 == 'S') or (play1 != 'S' and play2 == 'P')
return -1
else:
return 0
Source Code
def rps(play1,play2):
if play1 == play2:
return 0
if(play1=='P'and play2=='R')or(play1=='R'and
play2=='S')or(play1=='S'and play2=='P'):
return -1
else:
return 1
Screenshot
---
i actually corrected your code
this code will work without error
actually program has some more parts
if you want repost question, love to answer
all the best
IN PYTHON The code below does not load/work. Debug the following code so that it works....
AND logic gate simulation in Python: Please fix the code below so that it efficiently performs the operation of the AND logic gate in Python. (Leave comments in the edited code about what you changed) #if both values are 1, return true, other wise return false print ("Logic Gate Simulation: AND gate") def AND(x, y): if x == True and y == True: return True else: return False def main(): x = bool(input("Please...
Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() : Since Pizza object don't have it's own set() datastructure, the toppings in the pizza object are manimupated from out of the object. (-1.0) 2. __eq__() : How about "self.toppings == other.toppings" rather than "self.toppings - other.toppin == set())". Code: ## Program 1 ## --------------------------------- class Pizza: def __init__(self, s='M', top=set()): self.setSize(s) self.toppings = top def setSize(self, s): self.size = s def getSize(self): return self.size...
I need the create a Python code that makes a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game) Please help me see why my "continue" is asking the players to start a new game. Here is my code; user1= input("Whats your name? ") user2= input("And your name? ") a = input("%s, do yo want to choose...
Please write a Python program to check a tic-tac-toe game and show its winning result in detail. This is an application program of a 3-dimensional list or array. Your complete test run output must look as follows. This test really checks to make sure your program is performing perfectly to check every possible winning situation for X and O. GAME 0 is as follows: OOO OOO OOO O won by row 1 O won by row 2 O won by...
Please code in Python Revise the AbstractBag class so that it behaves as a subclass of AbstractCollection provided in the file abstractcollection.py. Abstractcollection.py code: class AbstractCollection(object): """An abstract collection implementation.""" # Constructor def __init__(self, sourceCollection = None): """Sets the initial state of self, which includes the contents of sourceCollection, if it's present.""" self.size = 0 if sourceCollection: for item in sourceCollection: self.add(item) # Accessor methods def isEmpty(self): """Returns True if len(self) == 0, or False otherwise.""" return len(self) == 0...
Java CSC252 Programming II Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that allows the user to play "Rock, Paper, Scissors". Write the RPS class. All code should be in one file. main() will be part of the RPS class, fairly small, and contain only a loop that asks the user if they want to play "Rock, Paper, Scissors". If they say yes, it calls the static method play() of the RPS class. If not, the program...
PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...
Page 3 of 7 (Python) For each substring in the input string t that matches the regular expression r, the method call re. aub (r, o, t) substitutes the matching substring with the string a. Wwhat is the output? import re print (re.aub (r"l+\d+ " , "$, "be+345jk3726-45+9xyz")) a. "be$jk3726-455xyz" c. "bejkxyz" 9. b. "be$jks-$$xyz" d. $$$" A object a- A (2) 10. (Python) What is the output? # Source code file: A.py class A init (self, the x): self.x-...
In python: The randrange(min, max) produces a random integer greater than or equal to min and less than max. So randrange(0,3) produces either 0, 1, or 2 Write a program that asks the user to input paper, rock, scissors, or done If they input something else, repeat the question. If they input 'done', exit the game loop. If they input rock, paper, or scissors, have the computer pick a random choice. Write a function that takes two strings, each 'rock', 'paper',...
Write a program in python that lets the user play the game Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...