# Zibzo

Members

3

• #### Days Won

1

Zibzo had the most liked content!

• Rank
Newbie

## Recent Profile Visitors

521 profile views

1. ## Rock Paper Scissors Beginners practice

@Zac Yes, that's a nice way to implement this idea. The code is probably much easier to read this way as multiple functions, rather than how I've shown as a bunch of if statements.
2. ## Rock Paper Scissors Beginners practice

@clyde21 So the line: while(1==1): essentially creates an infinite loop. Inside the loop, there is the main() function and then there's an input() as well. The loop won't continue until the input() function is cleared, so that's the reason for input('Press enter to play again'). Normally infinite while loops are considered bad in Python, so a better way to implement this is to include a cycle breakpoint as well. For example: while (breakPoint != 'x' or breakPoint != 'X'): main() import time time.sleep(1) breakPoint = input('Press enter to start again or press x to exit') So this is a very simplistic break point, but basically if x is entered, the while loop stops. That's the reason for the while(breakPoint != x), so if the variable breakPoint doesn't equal the string 'x', the loop will continue. Hope this helps!
3. ## Rock Paper Scissors Beginners practice

Rock Paper Scissors game made simply on Python. Very very simple, great project for beginners. Also an attached .py file def main(): import random botHand = random.randint(1,3) userHand = input("Pick rock, paper or scissors ") print("You pick " + userHand) if(botHand == 1): print("Computer picks scissors") elif(botHand == 2): print("Computer picks rock") elif(botHand == 3): print("Computer picks paper") import time time.sleep(2) if ((userHand == 'rock' or userHand == 'Rock')and botHand == 1): print('You win') elif ((userHand == 'rock' or userHand == 'Rock')and botHand == 2): print('You tie.') elif ((userHand == 'rock' or userHand == 'Rock')and botHand == 3): print('You lose.') elif ((userHand == 'paper' or userHand == 'Paper')and botHand == 1): print('You lose.') elif ((userHand == 'paper' or userHand == 'Paper')and botHand == 2): print('You win!') elif ((userHand == 'paper' or userHand == 'Paper')and botHand == 3): print('You tie.') elif ((userHand == 'scissors' or userHand == 'Scissors')and botHand == 1): print('You tie.') elif ((userHand == 'scissors' or userHand == 'Scissors')and botHand == 2): print('You lose.') elif ((userHand == 'scissors' or userHand == 'Scissors')and botHand == 3): print('You win!') else: print('INVALID input, try again') import time time.sleep(1) main() while (1==1): main() import time time.sleep(1) input('Press enter to start again') RockPaperScissors.py EDIT: For anyone wondering, yes I do know that I do not have to import the time module every single time, and I can import it once at the start. Just wanted to clear that with you guys.