DAY2: Python day 3&4
Published: 2023-11-05 13:30:59

Looks like writing everything down is a little bit time-consuming and inefficient, as I am aware of most of the content. For the beginner lessons, I will briefly write down what the lesson was about and include the end-of-the-lesson projects. 


## Python day3 

- `if`, `else`, and `elif` statements and conditional operators `<`,`>`, `<=`, `>=`, `==`

- nested `if` statements (`if` within another `if`)

- multiple `if` statements in succession

- logical operators `and`, `or`, and `not`

**End of the lesson project: Treasure Island**

```
print('''
*******************************************************************************
          |                   |                  |                     |
 _________|________________.=""_;=.______________|_____________________|_______
|                   |  ,-"_,=""     `"=.|                  |
|___________________|__"=._o`"-._        `"=.______________|___________________
          |                `"=._o`"=._      _`"=._                     |
 _________|_____________________:=._o "=._."_.-="'"=.__________________|_______
|                   |    __.--" , ; `"=._o." ,-"""-._ ".   |
|___________________|_._"  ,. .` ` `` ,  `"-._"-._   ". '__|___________________
          |           |o`"=._` , "` `; .". ,  "-._"-._; ;              |
 _________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______
|                   | |o;    `"-.o`"=._``  '` " ,__.--o;   |
|___________________|_| ;     (#) `-.o `"=.`_.--"_o.-; ;___|___________________
____/______/______/___|o;._    "      `".o|o_.--"    ;o;____/______/______/____
/______/______/______/_"=._o--._        ; | ;        ; ;/______/______/______/_
____/______/______/______/__"=._o--._   ;o|o;     _._;o;____/______/______/____
/______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_
____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____
/______/______/______/______/______/______/______/______/______/______/_____ /
*******************************************************************************
''')
print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.") 

#https://www.draw.io/?lightbox=1&highlight=0000ff&edit=_blank&layers=1&nav=1&title=Treasure%20Island%20Conditional.drawio#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1oDe4ehjWZipYRsVfeAx2HyB7LCQ8_Fvi%26export%3Ddownload

#Write your code below this line 👇
direction = input("You\'re at a forked path. Left or Right? ").lower()
if direction == "right": 
  print("fallen into a hole. Game over")
else:
  lake = input("There is an island in the middle of the lake. Wait or swim? ").lower()
  if lake == "swim":
    print("eaten by trout. Game over")
  else: 
    door = input("which door, red, yellow, or blue? ").lower()
    if door == "yellow": 
      print("You win!")
    elif door == "red":
      print ("burnt alive. Game over")
    else: 
      print ("eaten alive. Game over")
```

## Python day4


- creating a module by creating another file and `import`.
- random module`import random`

- `random.randint(1,4)`,`random.random()` functions

- list data structure `[a,b,c,d]`

- list index 

- `append()`function to add to the list 

- nested list `list[][]`
**End of the lesson project: Rock paper scissors**

```
rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''

#Write your code below this line 👇
import random

while True:
  listofchoices = [rock, paper, scissors]
  x = int(input("What do you Choose? Type 0 for Rock, 1 for Paper, or 2 for Scissors."))
  y = random.randint(0,2)

  player = listofchoices[x]
  computer = listofchoices[y]

  print(player)
  print(f"Computer chose:\n {computer}")
  if listofchoices[x] == listofchoices[y]: 
   print("Draw")
  if listofchoices[x-1] == listofchoices[y]:
    print("You win!")
  if listofchoices[y-1] == listofchoices[x]:
    print("You lose")
```