## DEV Community

Mike Kameta

Posted on • Updated on

# 100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 4 (Rock Paper Scissors)

Exercise 4.1 - Heads or Tails

import random

random_side = random.randint(0, 1)
if random_side == 1:
else:
print("Tails")

Exercise 4.2 - Banker Roulette

• When running the code it will ask for a seed number. import random

• List of names to use are Angela, Ben, Jenny, Michael, Chole

import random

🚨 Don't change the code below 👇
test_seed = int(input("Create a seed number: "))
random.seed(test_seed)

-Split string method
names_string = input("Give me everybody's names, separated by a comma. ")
names = names_string.split(", ")
🚨 Don't change the code above 👆

Write your code below this line 👇

-Get total items in a list using len().
num_items = len(names)

-Generate random numbers between 0 and the last index
random_choice = random.randint(0, num_items -1)

-Pick a random person to pay selected from random_choice
pay_the_bill = names[random_choice]

print(pay_the_bill + " is going to buy the meal today!")

Exercise 4.3 - Treasure Map

row1 = ["⬜️","️⬜️","️⬜️"]
row2 = ["⬜️","⬜️","️⬜️"]
row3 = ["⬜️️","⬜️️","⬜️️"]
map = [row1, row2, row3]
print(f"{row1}\n{row2}\n{row3}")

position = input("Where do you want to put the treasure? ")

horizontal = int(position)
vertical = int(position)

map[vertical - 1][horizontal - 1] = "X"

Project 4 - Rock, Paper, Scissors

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

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

scissors = '''
_______
---' _)_
___)
_
___)
(
)
---.
(__)
'''

-Write your code below this line 👇

import random

player_choice = input("Enter a choice (rock, paper or scissors)? ")
possible_actions = ("rock", "paper", "scissors")
computer_choice = random.choice(possible_actions)

print(f"\nYou chose {player_choice}, computer chose {computer_choice}.\n")

if player_choice == computer_choice:
print ("You both chose the same! Its a Tie ")
elif player_choice == "rock":
if computer_choice == "scissors":
print("Rock smashes scissors. You lose")
else:
print("Paper covers Rock, You Win")
elif player_choice == "paper":
if computer_choice == "rock":
print("Paper covers Rock. You Win")
else:
print("Scissors cuts Paper, You lose")
elif player_choice == "scissors":
if computer_choice == "rock":
print("Rock smashes Scissors, You lose")
else:
print("Scissors cuts paper, You win")
else:
print("You typed an invalid choice....Try again")