I just created my first python program

Sociobiology

Sociobiology

Fuchsia
Joined
Apr 9, 2022
Posts
10,922
Reputation
12,258
Python:
# Project 1: Rock paper scissors#
import random
import numpy

PlayChoice = 0
ComChoice = 0
score = 0
RoundNo = int(input("Select the number of rounds: "))

for i in range(RoundNo):
    PlayChoice = input(("Pick R Rock, Paper P, Scissors S: ")
    mylist = ["R","P","S"]
    ComChoice = random.choice(mylist)
#Rock variants
    if PlayChoice == "R" and ComChoice == "R":
        print ("We both chose Rock")
        score += 0
    elif  PlayChoice == "R" and ComChoice == "P":
        print ("I chose Rock, you win")
        score += 1
    elif  PlayChoice == "R" and ComChoice == "S":
        print ("I chose Rock, I win")
        score -= 0
#Paper variants
    elif  PlayChoice == "P" and ComChoice == "R":
        print ("I chose Paper, I win")
        score -= 0
    elif  PlayChoice == "P" and ComChoice == "P":
        print ("We both chose Paper")
        score += 0
    elif  PlayChoice == "P" and ComChoice == "S":
        print ("I chose Paper, you win")
        score += 1
#Scissors variants
    elif  PlayChoice == "S" and ComChoice == "R":
        print ("I chose Scissors, you win")
        score += 1
    elif  PlayChoice == "S" and ComChoice == "P":
        print ("I chose Scissors, lose win")
        score -= 0
    elif  PlayChoice == "S" and ComChoice == "S":
        print ("We both chose Scissors")
        score += 0
    else:
        break
print("Game over, you won ",score,"/",RoundNo,".")

How to get good at this shit fellow niggacels?
 
  • +1
Reactions: Jason Voorhees and PlayersGetPlayed
Just pay the ai to do it for u
 
  • +1
Reactions: Deleted member 52226, Nick.Harte and PlayersGetPlayed
@thecel how do I get good at this shit nigga?
 
@Jason Voorhees
 
Python:
# Project 1: Rock paper scissors#
import random
import numpy

PlayChoice = 0
ComChoice = 0
score = 0
RoundNo = int(input("Select the number of rounds: "))

for i in range(RoundNo):
    PlayChoice = input("Pick R Rock, Paper P, Scissors S: ")
    mylist = ["R","P","S"]
    ComChoice = random.choice(mylist)
#Rock variants
    if PlayChoice == "R" and ComChoice == "R":
        print ("We both chose Rock")
        score += 0
    elif  PlayChoice == "R" and ComChoice == "P":
        print ("I chose Paper, you win")
        score += 1
    elif  PlayChoice == "R" and ComChoice == "S":
        print ("I chose Scissors, you win")
        score += 1
#Paper variants
    elif  PlayChoice == "P" and ComChoice == "R":
        print ("I chose Rock, you win")
        score += 1
    elif  PlayChoice == "P" and ComChoice == "P":
        print ("We both Paper")
        score += 0
    elif  PlayChoice == "P" and ComChoice == "S":
        print ("I chose Scissors, I win")
        score += 0
#Scissors variants
    elif  PlayChoice == "S" and ComChoice == "R":
        print ("I chose Rock, I win")
        score -= 0
    elif  PlayChoice == "S" and ComChoice == "P":
        print ("I chose Paper, you win")
        score += 1
    elif  PlayChoice == "S" and ComChoice == "S":
        print ("We both chose Scissors")
        score += 0
    else:
        break
print("Game over, you won ",score,"/",RoundNo," rounds.")
fixed it
 
good luck picking food from garbage in 5 years programmercel
 
  • JFL
Reactions: Sociobiology
. I would personally just do it with switch cases or a do-while loop and divide it into functions to improve readability and also implement some kind of error handling for false inputs. Numpy import also seems unnecessary. Otherwise the code seems fine once OP has a bit of experience he can learn more about vectorization techniques to perform operations on entire arrays on more complex large dataset problems , rather than element-by-element that but for simple problems small sample set problmes like these it's fine. He has plenty of time to learn these things.
@Jason Voorhees
 
Last edited:
  • +1
  • Love it
Reactions: Sociobiology and Nick.Harte
Just pay the ai to do it for u
AI is actually pretty good for these kinds of array based operations on data sets with smaller samples. I use it all thr time
 

Similar threads

menas
Replies
214
Views
31K
Snowskinned
S
Zagro
Replies
357
Views
52K
6´3 LTN
6´3 LTN
TheBlackpilledOne
Replies
3
Views
279
obscuredusk
obscuredusk
chadbeingmade
Replies
210
Views
21K
genetically fucked
genetically fucked

Users who are viewing this thread

Back
Top