I just created my first python program

Unhuman

Unhuman

Who dares wins.
Joined
Apr 9, 2022
Posts
9,961
Reputation
11,027
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: Unhuman
. 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: Unhuman 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

Spidermanne2returns
Replies
21
Views
4K
wannabe_mogger
W
Spidermanne2returns
Replies
17
Views
3K
Annihilator
Annihilator
Spidermanne2returns
Replies
16
Views
3K
Flawless_fliy
Flawless_fliy
Spidermanne2returns
Replies
18
Views
3K
Spidermanne2returns
Spidermanne2returns

Users who are viewing this thread

Back
Top