DEV Community

loading...
Cover image for My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 4

My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 4

abeck617 profile image Anthony Beckford🚀 ・1 min read

Day 4 - Rock, Paper, Scissors game

import random

rock = '''
_______
---' _)
(
)
(
)
(
)
---.
(__)
'''

paper = '''
_______
---' _)_
___)
_
)
_
)
---.
_______)
'''

scissors = '''
_______
---' _)_
___)
_
___)
(
)
---.
(__)
'''
game_image = [rock, paper, scissors]

user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))
print(game_image[user_choice])

computer_choice = random.randint(0, 2)
print("computer chose:")
print(game_image[computer_choice])

if user_choice >= 3 or user_choice < 0:
print("You typed an invalid number, you lose!")
elif user_choice == 0 and computer_choice == 2:
print('You Win!')
elif computer_choice == 0 and user_choice == 2:
print("You Lose!")
elif computer_choice > user_choice:
print("You Lose!")
elif user_choice > computer_choice:
print("You Win!")
elif computer_choice == user_choice:
print("Draw game!")

Key Takeaways:

  1. Learned about Randomisation adn Python List

Discussion (0)

pic
Editor guide