Skip to content

Commit bf8e312

Browse files
authored
Add files via upload
0 parents  commit bf8e312

File tree

9 files changed

+217
-0
lines changed

9 files changed

+217
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Day 6 - Python Functions
2+
## Concepts Practiced
3+
- Defining and Calling Python Functions
4+
- Indentation in Python
5+
- While Loops
6+
## Escaping the Maze
7+
[Reeborg's Maze](https://reeborg.cs20.ca/?lang=en&mode=python&menu=%2Fworlds%2Fmenus%2Fsk_menu.json&name=Maze&url=%2Fworlds%2Ftutorial_en%2Fmaze1.json)
8+
![day006](https://user-images.githubusercontent.com/98851253/154312745-8abc5397-27b7-4a1d-b29c-3a1527280868.gif)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def turn_right():
2+
turn_left()
3+
turn_left()
4+
turn_left()
5+
6+
while front_is_clear():
7+
move()
8+
turn_left()
9+
10+
while not at_goal():
11+
if right_is_clear():
12+
turn_right()
13+
move()
14+
elif front_is_clear():
15+
move()
16+
else:
17+
turn_left()
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import random
2+
3+
rock_0 = """
4+
_______
5+
---' ____)
6+
(_____)
7+
(_____)
8+
(____)
9+
---.__(___)
10+
"""
11+
12+
paper_1 = """
13+
_______
14+
---' ____)____
15+
______)
16+
_______)
17+
_______)
18+
---.__________)
19+
"""
20+
21+
scissors_2 = """
22+
_______
23+
---' ____)____
24+
______)
25+
__________)
26+
(____)
27+
---.__(___)
28+
"""
29+
30+
# Choose between Rock (0), Paper (1), or Scissors (2)
31+
user_choice = input(
32+
"\nWhat do you choose? Type: \n0 for Rock \n1 for Paper \n2 for Scissors\n"
33+
)
34+
35+
computer_choice = random.randint(0, 2)
36+
37+
# Print the user's choice
38+
if not user_choice.isdigit():
39+
print("You've entered an invalid value, Game Over.\n")
40+
elif int(user_choice) > 2:
41+
print("You've entered an invalid number, Game Over.\n")
42+
else:
43+
user_choice = int(user_choice)
44+
if user_choice > 2:
45+
print(
46+
"You've entered an invalid number, try again and choose a number between 0-2."
47+
)
48+
elif user_choice == 0 or user_choice == 1 or user_choice == 2:
49+
if user_choice == 0:
50+
print(f"You chose: Rock {rock_0}")
51+
elif user_choice == 1:
52+
print(f"You chose: Paper {paper_1}")
53+
elif user_choice == 2:
54+
print(f"You chose: Scissors {scissors_2}")
55+
56+
# Print the computer's choice & determine the winner
57+
# Computer chooses Rock - You lose, its a draw, you winS
58+
if computer_choice == 0:
59+
print(f"The computer chose: Rock {rock_0}")
60+
if user_choice == 2:
61+
print("You lose, Rock beats scissors.\n")
62+
elif user_choice == 0:
63+
print("It's a draw!\n")
64+
else:
65+
print("You Win!! Paper beats rock.\n")
66+
67+
# Computer chooses Paper - You lose, its a draw, you win
68+
if computer_choice == 1:
69+
print(f"The computer chose: Paper {paper_1}")
70+
if user_choice == 0:
71+
print("You lose, Paper beats rock.\n")
72+
elif user_choice == 1:
73+
print("It's a draw!\n")
74+
else:
75+
print("You win!! Scissors beats paper.\n")
76+
77+
# Computer chooses Scissors - You lose, its a draw, you win
78+
if computer_choice == 2:
79+
print(f"The computer chose: Scissors {scissors_2}")
80+
if user_choice == 1:
81+
print("You lose, Scissors beats paper.\n")
82+
elif user_choice == 2:
83+
print("It's a draw!\n")
84+
else:
85+
print("You win!! Rock beats paper.\n")
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
print('''
2+
*******************************************************************************
3+
| | | |
4+
_________|________________.=""_;=.______________|_____________________|_______
5+
| | ,-"_,="" `"=.| |
6+
|___________________|__"=._o`"-._ `"=.______________|___________________
7+
| `"=._o`"=._ _`"=._ |
8+
_________|_____________________:=._o "=._."_.-="'"=.__________________|_______
9+
| | __.--" , ; `"=._o." ,-"""-._ ". |
10+
|___________________|_._" ,. .` ` `` , `"-._"-._ ". '__|___________________
11+
| |o`"=._` , "` `; .". , "-._"-._; ; |
12+
_________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______
13+
| | |o; `"-.o`"=._`` '` " ,__.--o; |
14+
|___________________|_| ; (#) `-.o `"=.`_.--"_o.-; ;___|___________________
15+
____/______/______/___|o;._ " `".o|o_.--" ;o;____/______/______/____
16+
/______/______/______/_"=._o--._ ; | ; ; ;/______/______/______/_
17+
____/______/______/______/__"=._o--._ ;o|o; _._;o;____/______/______/____
18+
/______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_
19+
____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____
20+
/______/______/______/______/______/______/______/______/______/______/______/
21+
*******************************************************************************
22+
''')
23+
print("Welcome to Treasure Island.")
24+
print("Your mission is to find the treasure.")
25+
choice1 = input('You\'re at a cross road, Where do you want to go? \n'
26+
'Type "left" to take the left path or '
27+
'Type "right" to take the right path.\n').lower()
28+
if choice1 == "left":
29+
choice2 = input('You\'ve come to a lake. \n'
30+
'There is an island in the middle of the lake. \n'
31+
'Type "wait" to wait for a boat or '
32+
'type "swim" to swim across.\n').lower()
33+
if choice2 == "wait":
34+
choice3 = input('You arrive at the island unharmed.\nThere is a house with 3 doors.\n'
35+
'One "red", one "yellow" and one "blue". Which color do you choose?\n').lower()
36+
if choice3 == "red":
37+
print("It's a room full of fire. Game Over.")
38+
elif choice3 == "yellow":
39+
print("You found the treasure. You Win!")
40+
elif choice3 == "blue":
41+
print("You enter a room of beasts. Game Over.")
42+
else:
43+
print("You got attacked by an angry gator. Game Over.")
44+
else:
45+
print("You fell into a hole. Game Over.")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Working with Variables in Python to Manage Data
2+
3+
## Concepts Practised
4+
5+
- Print Statement
6+
- Input Function
7+
- String Manipulation
8+
- Variables
9+
- Basic I/O Operations
10+
- Code Structure
11+
12+
## Band Name Generator
13+
14+
![day01](https://user-images.githubusercontent.com/98851253/154177081-2c53df2d-777b-4deb-8e38-5742ecd7282f.gif)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
print("Welcome to the Band Name Generator")
2+
city = input("What is the name of the city you grew up in?\n")
3+
pet_name = input("What's your pet's name?\n")
4+
print("Your band name could be " + city + " " + pet_name)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Password Generator
2+
![Image](https://github.com/user-attachments/assets/4dd9f74a-7046-447b-bb02-c9e05ca4aad3)
3+
4+
## Concepts:
5+
### Python Loops
6+
- Using the for loop with Python Lists
7+
- For loops and the range() function
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import random
2+
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
3+
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
4+
symbols = ['!','#','$','%','&','(',')','*','+']
5+
6+
print("\nWelcome to the PyPassword Generator!")
7+
nr_letters = int(input("How many letters would you like in your password?\n"))
8+
nr_symbols = int(input("How many symbols would you like?\n"))
9+
nr_numbers = int(input("How many numbers would you like?\n"))
10+
11+
# Generate Password from Input
12+
password_list = []
13+
for char in range(0, nr_letters):
14+
password_list.append(random.choice(letters))
15+
for char in range(0, nr_symbols):
16+
password_list.append(random.choice(symbols))
17+
for char in range(0, nr_numbers):
18+
password_list.append(random.choice(numbers))
19+
20+
# Shuffle Password
21+
password = ""
22+
random.shuffle(password_list)
23+
for char in password_list:
24+
password += char
25+
26+
print(f"Your password is: \n{password}")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
print("Welcome to the tip calculator!")
2+
bill = float(input("What was the total bill? $"))
3+
tip = int(input("How much tip would you like to give? 10 12 15 etc: "))
4+
people = int(input("How many people to split the bill? "))
5+
6+
tip_as_percentage = tip / 100
7+
total_tip_amount = bill * tip_as_percentage
8+
total_bill = bill + total_tip_amount
9+
bill_per_person = total_bill / people
10+
final_amount = round(bill_per_person, 2)
11+
print(f"Each person should pay: ${final_amount} ")

0 commit comments

Comments
 (0)