Day 14 - 100 Days of Code: 2 player rock, paper, scissor!

preview_player
Показать описание
00:00 2 player game!
01:39 Share your code
01:55 Next up!
Рекомендации по теме
Комментарии
Автор

Here's mine. Fairly simple. The only thing I can't seem to get right is only allowing those 3 letters. If I type other letters, they are able to produce an outcome.

from getpass import getpass as input

print("Let's play a game of Rock, Paper, Scissors!")
print()
print("R for Rock, P for Paper, and S for Scissors.")
print()

R = 'Rock'
P = 'Paper'
S = 'Scissor'

playerOne = input("Player One, please select your move: ")
print()
playerTwo = input("Player Two, please select your move: ")

if playerOne == "R" and playerTwo == "S":
print()
print("Player One wins!")
elif playerOne == "P" and playerTwo == "R":
print()
print("Player One wins!")
elif playerOne == "S" and playerTwo == "P":
print()
print("Player One wins!")
elif playerOne == "S" and playerTwo == "R":
print()
print("Player Two wins!")
elif playerOne == "R" and playerTwo == "P":
print()
print("Player Two wins!")
elif playerOne == "P" and playerTwo == "S":
print()
print("Player Two wins!")
elif playerOne == playerTwo:
print()
print("It's a tie!")
else:
print()
print("Invalid input.")

RichOnStream
Автор

from getpass import getpass as input
p1 = input("p1 mowe: r, p, or s?")
p2 = input("p2 mowe: r, p, or s?")
if p2=="r"and p1=="p"or p2=="s"and p1=="p"or p2=="p"and p1=="r":
print("p2 win")
elif p1=="r"and p2=="p"or p1=="s"and p2=="p"or p1=="p"and p2=="r":
print("p1 win")
else:
print("draw")

HawasMusazai
Автор

Please can someone explain to me why the "from getpass import getpass as input" doesn't work in pycharm ? Please !

lepoussin
Автор

how to make this code i am very confused

siddharthkoshti
Автор

I'm curious whether there is a way to make this faster than using a lot of "If, Elif and Nested If statements?"

BlackHeart-dgoe
Автор

print("\033[35mHoje, nós vamos jogar um jogo clássico, o pedra papel tesoura.\033[0m")
print("Para isso, nós vamos usar o nome do objeto escolhido, ou seja, se for tesoura colocar tesoura e assim por diante!")
print()
name1 = input("Jogador 01 qual seu nome: ")
print()
name2 = input("Jogador 02 qual seu nome? ")
print()
print("Antes de começar nós vamos ver se você entendeu!")
Tesoura = input("Quando for Tesoura o que você vai colocar? ")
Papel = input("Quando for Papel o que você vai colocar? ")
Pedra = input("Quando for Pedra o que você vai colocar? ")
if Tesoura == "Tesoura" or Tesoura == "tesoura" and Papel == "Papel" or Papel == "papel" and Pedra == "Pedra" or Pedra == "pedra":
print("Isso, podemos começar!")
else:
print("Você não entendeu ainda, volte no enunciado!")
from getpass import getpass as input
j01 = input("Jogador 01: Pedra, Papel ou Tesoura? ")
j02 = input("Jogador 02: Pedra Papel ou Tesoura? ")
if j01 == "Tesoura" and j02 == "Papel":
print()
print(f"{name1} \033[32mVENCEU!\33[0m")
elif j01 == "Tesoura" and j02 == "Pedra":
print(f"{name2} \033[32mVENCEU!\33[0m")
elif j01 == "Pedra" and j02 == "Papel":
print(f"{name2} \033[32mVENCEU!\33[0m")
print()
elif j01 == "Pedra" and j02 == "Tesoura":
print()
print(f"{name1} \033[32mVENCEU!\33[0m")
elif j01 == "Papel" and j02 == "Pedra":
print()
print(f"{name1} \033[32mVENCEU!\33[0m")
elif j01 == "Papel" and j02 == "Tesoura":
print()
print(f"{name2} \033[32mVENCEU!\33[0m")

BrunoHorta-vxvp
Автор

import random
options = ("r", "p", "s")
player_2 = random.choice(options)
print(" WELCOME TO OUR OWN ROCK VS PAPER VS SCISSORS DEATH BATTLE!!!!")
print()
player1 = input("Player Name: ")
print(player1, "your opponent will be me, (The Computer), so be ready!!!")
print()
weapon = input("Choose you weapon (r, s, p)!!! ")
if weapon == "r" and player_2 == "s":
print("You chose rock, and your opponent chose scissors, you win!!!")
if weapon == "r" and player_2 == "r":
print("You chose rock, and your opponent chose rock, it's a draw!!!")
if weapon == "r" and player_2 == "p":
print("You chose rock, and your opponent chose paper, you lose!!!")
if weapon == "p" and player_2 == "p":
print("You chose paper, and your opponent chose paper, it's a draw!!!")
if weapon == "p" and player_2 == "s":
print("You chose paper, and your opponent chose scissors, you lose!!!")
if weapon == "p" and player_2 == "r":
print("You chose paper, and your opponent chose rock, you win!!!")
if weapon == "s" and player_2 == "s":
print("You chose scissors, and your opponent chose scissors, it's a draw!!!")
if weapon == "s" and player_2 == "p":
print("You chose scissors, and your opponent chose paper, you lose!!!")
if weapon == "s" and player_2 == "r":
print("You chose scissors, and your opponent chose rock, you lose!!!")

nacholaplace
Автор

I don't undrestand why the code does not work.

therelaxedguy_y
Автор

Came in at a bit of a different angle. Using the solution, I modified it to make the computer be Player 2.

import random

# Set up the emojis
rock = "\U0001faa8"
paper = "\U0001f4c4"
scissors = "\u2702\uFE0F"
happy = "\U0001f601"
sad = "\U0001f62d"

# Text colors / formatting
green = "\033[32m"
yellow = "\033[93m"
red = "\033[31m"
reset = "\033[0m"

# Sets random options for computer player (aka Player 2)
options = ['r', 'p', 's'] # (r)ock, (p)aper, (s)cissors
player_2 = random.choice(options) # picks randomly for Player 2

print(str.center(f" E P I C {rock} {paper} {scissors} B A T T L E ", 50))
print(str.center(f"Play against the computer (player 2) in this classic game.", 0))
print()
print("Select your move (R)ock, (P)aper or (S)cissors: ")
print()

player_1 = input("Ready Player 1: ").lower()
print()

if player_1 == "r": # rock > scissors but < paper
if player_2 == "s": # scissors
print(f"You chose rock. Player 2 chose scissors.\nRock blunts scissors, so you {green}win!{reset}{happy}")
elif player_2 == "p": # paper
print(f"You chose rock. Player 2 chose paper.\nPaper wraps rock, so you {red}lose!{reset}{sad}")
else: # If Player 2 picks the same, it is caught by the else statement
print(f"You both picked {rock} {rock} - it's a {yellow}draw!{reset} Better luck next time.")
elif player_1 == "p": # paper > rock but < scissors
if player_2 == "r": # rock
print(f"You chose paper. Player 2 chose rock.\nPaper wraps rock, so you {green}win!{reset}{happy}")
elif player_2 == "s": # scissors
print(f"You chose paper. Player 2 chose scissors.\nScissors cut paper, so you {red}lose!{reset}{sad}")
else: # If Player 2 picks the same, it is caught by the else statement
print(f"You both chose {paper} {paper} - it's a {yellow}draw!{reset} Better luck next time.")
elif player_1 == "s": # scissors < rock but > paper
if player_2 == "r": # rock
print(f"You chose scissors. Player 2 chose rock.\nRock blunts scissors, so you {red}lose!{reset}{sad}")
elif player_2 == "p": # paper
print(f"You chose scissors. Player 2 chose paper.\nScissors cut paper, so you {green}win!{reset}{happy}")
else: # If Player 2 picks the same, it is caught by the else statement
print(f"You both chose {scissors} {scissors} - it's a {yellow}draw!{reset} Better luck next time.")
else:
print("Invalid input Player 1.\nStart over and remember the options are R, P or S!")

ellisjwright
Автор

print("ROCK PAPER SCISSORS SHOWDOWN")
print(" r for rock, s for scissors and p for paper")
r = 'rock'
s = 'scissors'
p = 'paper'
print ("select your move r p or s")
player_1 = input("pick your poison:")
player_2 = input("pick your poision:")
if player_1 == r and player_2 == s:
print("player 1 wins")
elif player_1 == s and player_2 == p:
print("player 1 wins")
elif player_1 == p and player_2 == r:
print('player 1 wins')
elif player_1 == s and player_2 == r:
print('player 2 wins')
elif player_1 == p and player_2 == s:
print('player 2 wins')
elif player_1 == r and player_2 == p:
print("player 2 wins")
elif player_1 == r and player_2 == r:
print("you tied, please go again")
elif player_1 == s and player_2 == s:
print("you tied, please go again")
elif player_1 == p and player_2 == p:
print("you tried, please go again")

Sylvestt
Автор

Hi where can I find the solution please? Day 14

notedv
Автор

I m compiling on pycharm how to ask explicitly from users without letting them know sir can i have solution

harshshah
Автор

8 lines. Simple and lazy..

P1 = input("Player 1! Rock, Paper or Scissors? R, P or S? ")
P2 = input("Player 2! R, P or S? ")
if P1 == "R" and P2 == "R" or P1== "P" and P2 == "P" or P1 == "S" and P2 == "S":
print ("Draw!")
if P1 == "R" and P2 == "S" or P1 == "P" and P2 == "R" or P1 == "S" and P2 == "P":
print("Player 1 wins!")
if P2 == "R" and P1 == "S" or P2 == "P" and P1 == "R" or P2 == "S" and P1 == "P":
print("Player 2 wins!")

ChristopherFowler-pj
Автор

why am i stuck in Player one's rock is smothered by player two's paper even tho i double triple quadruple check my code multiple times :x

perfectionist
Автор

solution:









this code on 52 lines

import time
print("E P I C ROCK PAPER SCISSORS B A T T L E")
time.sleep(1)

print("")
print("Select your move (Rock, Paper or Scissors)")
print("")
while True:
choices = ['rock', 'paper', 'scissors']
player_1 = ()
player_2 = ()
while player_1 not in choices:
player_1 = input("(player 1) rock, paper or scissors?: ")
while player_2 not in choices:
player_2 = input("(player 2) rock, paper or scissors?: ")
if player_1 == player_2:
print("player_1: ", player_1)
print("player_2: ", player_2)
print("Tie!")
elif player_1 == "rock":
if player_2 == "paper":
print("player_1: ", player_1)
print("player_2: ", player_2)
print("PLAYER 2 WIN!")
if player_2 == "scissors":
print("player_1: ", player_1)
print("player_2: ", player_2)
print("PLAYER 1 WIN!")
elif player_1 == "scissors":
if player_2 == "paper":
print("player_1: ", player_1)
print("player_2: ", player_2)
print("PLAYER 1 WIN!")
if player_2 == "rock":
print("player_1: ", player_1)
print("player_2: ", player_2)
print("PLAYER 2 WIN!")
elif player_1 == "paper":
if player_2 == "scissors":
print("player_1: ", player_1)
print("player_2: ", player_2)
print("PLAYER 2 WIN!")
if player_2 == "rock":
print("player_1: ", player_1)
print("player_2: ", player_2)
print("PLAYER 1 WIN!")

play_again = input("Play again? (yes/no): ").lower()
if play_again != "yes":
break

print("Bye!")

urakadze
Автор

I am having trouble with my code printing the else statement and ignoring if and elif, even though i indenetd. please help


import random

r = "rock"
p = "paper"
s = "scissors"
option = [r, p, s]
player1 = input(f"Player 1, choose {r}, {p}, or {s}:\n")
player2 = random.choice(option)
while True:
if player1 == p and player2 == r or player1 == r and player2 == s:
if player1 == s and player2 == p:
print(f"Player 1 wins! {player1} beats {player2}")
elif player1 == p and player2 == p or player1 == r and player2 == r:
if player1 == s and player2 == s:
print("It's a draw!")
else:
print(input(f"Player 2 wins! {player2} beats {player1}"))
exit = input("Do you want to exit? ")
if exit == "yes":
break

VeronicaThibodeaux
Автор

Came up with my solution in 30 lines... not 38... 🤔😉 thanks for this, been learning a ton.

kristianrjsYT
Автор

💥Wow, every day the broth absorbs more🤯, but it's still interesting👏

universoemconvergencia
Автор

from getpass import getpass as input
import random

print("Rock, Paper, Scissors, Shoot!")
move = input("Select your move (R, P, or S): ").upper()

choices = ['R', 'P', 'S']
computer = random.choice(choices)

print(f"Computer chose {computer}")

if move == computer:
print("It's a tie!")
elif (move == "R" and computer == "S") or (move == "S" and computer == "P") or (move == "P" and computer == "R"):
print("You win!")
else:
print("You lose!")

Sandeep_jha
Автор

rock paper scissors

print("Let's play a game of Rock, Paper, Scissors!")
print()
print("R for Rock, P for Paper, and S for Scissors.")
print()

R = 'R'
P = 'P'
S = 'S'
p1point=0
p2point=0
while True:
playerOne = input("Player One, please select your move: ")
print()
playerTwo = input("Player Two, please select your move: ")

if playerOne == "R" and playerTwo == "S":
print()
print("Player One wins!")
p1point += 1
elif playerOne == "P" and playerTwo == "R":
print()
print("Player One wins!")
p1point += 1
elif playerOne == "S" and playerTwo == "P":
print()
print("Player One wins!")
p1point += 1
elif playerOne == "S" and playerTwo == "R":
print()
print("Player Two wins!")
p2point += 1
elif playerOne == "R" and playerTwo == "P":
print()
print("Player Two wins!")
p2point += 1
elif playerOne == "P" and playerTwo == "S":
print()
print("Player Two wins!")
p2point += 1
elif playerOne == playerTwo:
print()
print("It's a tie!")
if p1point==3:
print("Player One wins the game!")
break
if p2point==3:
print("Player Two wins the game!")
break
if playerOne not in ["R", "P", "S"] or playerTwo not in ["R", "P", "S"]:
print("Invalid Input.")
print()
print("Please select R, P, or S.")
continue

lyrica