Made an epic showcase website and API!

This commit is contained in:
rzmk 2021-08-17 16:39:42 -04:00
parent 9e21e4dbdd
commit 1907fad7c5
89 changed files with 36444 additions and 3 deletions

View file

@ -0,0 +1,10 @@
#1. Create a greeting for your program.
print("Welcome to the band name generator!")
#2. Ask the user for the city that they grew up in.
city_name = input("What's the name of the city you grew up in?\n")
#3. Ask the user for the name of a pet.
pet_name = input("What's your pet's name?\n")
#4. Combine the name of their city and pet and show them their band name.
print("Your band name could be " + city_name + " " + pet_name + "!")
#5. Make sure the input cursor shows on a new line, see the example at:
# https://band-name-generator-end.appbrewery.repl.run/

16
projects/Day 10/art.py Normal file
View file

@ -0,0 +1,16 @@
logo = """
_____________________
| _________________ |
| | Pythonista 0. | | .----------------. .----------------. .----------------. .----------------.
| |_________________| | | .--------------. || .--------------. || .--------------. || .--------------. |
| ___ ___ ___ ___ | | | ______ | || | __ | || | _____ | || | ______ | |
| | 7 | 8 | 9 | | + | | | | .' ___ | | || | / \ | || | |_ _| | || | .' ___ | | |
| |___|___|___| |___| | | | / .' \_| | || | / /\ \ | || | | | | || | / .' \_| | |
| | 4 | 5 | 6 | | - | | | | | | | || | / ____ \ | || | | | _ | || | | | | |
| |___|___|___| |___| | | | \ `.___.'\ | || | _/ / \ \_ | || | _| |__/ | | || | \ `.___.'\ | |
| | 1 | 2 | 3 | | x | | | | `._____.' | || ||____| |____|| || | |________| | || | `._____.' | |
| |___|___|___| |___| | | | | || | | || | | || | | |
| | . | 0 | = | | / | | | '--------------' || '--------------' || '--------------' || '--------------' |
| |___|___|___| |___| | '----------------' '----------------' '----------------' '----------------'
|_____________________|
"""

48
projects/Day 10/main.py Normal file
View file

@ -0,0 +1,48 @@
from art import logo
#Calculator
# Add
def add(n1, n2):
return n1 + n2
# Subtract
def subtract(n1, n2):
return n1 - n2
# Multiply
def multiply(n1, n2):
return n1 * n2
# Divide
def divide(n1, n2):
return n1 / n2
# Calculator dict
operations = {
"+": add,
"-": subtract,
"*": multiply,
"/": divide,
}
def calculator():
print(logo)
num1 = float(input("What's the first number?: "))
num2 = float(input("What's the second number?: "))
for symbol in operations:
print(symbol)
operation_symbol = input("Pick an operation: ")
answer = operations[operation_symbol](num1, num2)
print(f"{num1} {operation_symbol} {num2} = {answer}")
check = input(f"Type 'y' to continue calculating with {answer}, or type 'n' to exit.: ")
while check == "y":
operation_symbol = input("Pick another operation: ")
old_num = answer
num3 = float(input("What's the next number?: "))
answer = operations[operation_symbol](answer, num3)
print(f"{old_num} {operation_symbol} {num3} = {answer}")
check = input(f"Type 'y' to continue calculating with {answer}, or type 'n' to exit.: ")
calculator()
calculator()

14
projects/Day 11/art.py Normal file
View file

@ -0,0 +1,14 @@
logo = """
.------. _ _ _ _ _
|A_ _ |. | | | | | | (_) | |
|( \/ ).-----. | |__ | | __ _ ___| | ___ __ _ ___| | __
| \ /|K /\ | | '_ \| |/ _` |/ __| |/ / |/ _` |/ __| |/ /
| \/ | / \ | | |_) | | (_| | (__| <| | (_| | (__| <
`-----| \ / | |_.__/|_|\__,_|\___|_|\_\ |\__,_|\___|_|\_\\
| \/ K| _/ |
`------' |__/
"""

63
projects/Day 11/main.py Normal file
View file

@ -0,0 +1,63 @@
from art import logo
# from replit import clear
import random
program_end = False
def continue_blackjack():
program_end = False
while program_end == False:
user_hand.append(random.choice(cards))
user_sum = sum(user_hand)
print(f"Your cards: {user_hand}, current score: {user_sum}")
print(f"Computer's first card: {computer_hand[0]}")
if user_sum > 21:
return
ask_continue = input("Type 'y' to get another card, type 'n' to pass: ")
if ask_continue == "y":
continue_blackjack()
else:
program_end = True
return
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
user_hand = []
user_hand.append(random.choice(cards))
user_hand.append(random.choice(cards))
user_sum = sum(user_hand)
computer_hand = [random.choice(cards)]
computer_sum = computer_hand[0]
response = input("Do you want to play a game of Blackjack? Type 'y' or 'n': ")
if response == "y":
print(logo)
print(f"Your cards: {user_hand}, current score: {user_sum}")
print(f"Computer's first card: {computer_hand[0]}")
ask_continue = input("Type 'y' to get another card, type 'n' to pass: ")
if ask_continue == "y":
continue_blackjack()
else:
program_end = True
elif response == "n":
quit()
user_sum = sum(user_hand)
print(f"Your final hand: {user_hand}, final score: {user_sum}")
computer_total_cards = random.randint(0, len(user_hand))
if computer_total_cards > 0:
for i in range(computer_total_cards-1):
computer_hand.append(random.choice(cards))
computer_sum = sum(computer_hand)
print(f"Computer's final hand: {computer_hand}, final score: {computer_sum}")
if user_sum >= 21 and computer_sum >= 21:
print("Tie! You both drew 21 or over!")
elif user_sum > 21:
print("You went over. You lose!")
elif computer_sum > 21:
print("Opponent went over. You win!")
else:
if (21-user_sum) > (21-computer_sum):
print("Computer is closer to 21. You lose!")
else:
print("You're closer to 21. You win!")

10
projects/Day 12/art.py Normal file
View file

@ -0,0 +1,10 @@
logo = """
_____ _____ _ _ _ _ _
| __ \ |_ _| | | \ | | | | | |
| | \/_ _ ___ ___ ___ | | | |__ ___ | \| |_ _ _ __ ___ | |__ ___ _ __| |
| | __| | | |/ _ \/ __/ __| | | | '_ \ / _ \ | . ` | | | | '_ ` _ \| '_ \ / _ \ '__| |
| |_\ \ |_| | __/\__ \__ \ | | | | | | __/ | |\ | |_| | | | | | | |_) | __/ | |_|
\____/\__,_|\___||___/___/ \_/ |_| |_|\___| \_| \_/\__,_|_| |_| |_|_.__/ \___|_| (_)
"""

28
projects/Day 12/main.py Normal file
View file

@ -0,0 +1,28 @@
from random import randint
from art import logo
print(logo)
print("Welcome to the Number Guessing Game!")
print("I'm thinking of a number between 1 and 100.")
actual_answer = randint(1, 100)
difficulty = input("Choose a difficulty. Type 'easy' or 'hard': ")
if difficulty == "easy":
guesses = 10
elif difficulty == "hard":
guesses = 5
while guesses > 0:
print(f"You have {guesses} attempts remaining to guess the number.")
answer = input("Make a guess: ")
if int(answer) < actual_answer:
print("Too low.\nGuess again.")
elif int(answer) > actual_answer:
print("Too high.\nGuess again.")
elif int(answer) == actual_answer:
break
guesses -= 1
if int(answer) == actual_answer:
print(f"You got it! The answer was {actual_answer}.")
else:
print("You've run out of guesses. You lose.")

44
projects/Day 13/main.py Normal file
View file

@ -0,0 +1,44 @@
############DEBUGGING#####################
# Describe Problem
def my_function():
for i in range(1, 21): # cannot be 20, as that would be out of bounds
if i == 20:
print("You got it")
my_function()
# # Reproduce the Bug
from random import randint
dice_imgs = ["", "", "", "", "", ""]
dice_num = randint(0, 5) # range includes both endpoints
print(dice_imgs[dice_num])
# # Play Computer
year = int(input("What's your year of birth?"))
if year > 1980 and year < 1994:
print("You are a millenial.")
elif year >= 1994: # make sure 1994 itself is accounted for
print("You are a Gen Z.")
# # Fix the Errors
age = input("How old are you?")
if int(age) > 18: # cast age
print(f"You can drive at age {age}.") # indent within if statement, and make sure to put f for f string
# #Print is Your Friend
pages = 0
word_per_page = 0
pages = int(input("Number of pages: "))
word_per_page = int(input("Number of words per page: ")) # remember = (declaration) is different from == (conditional)
total_words = pages * word_per_page
print(total_words)
# #Use a Debugger
def mutate(a_list):
b_list = []
for item in a_list:
new_item = item * 2
b_list.append(new_item) # watch your indent!
print(b_list)
mutate([1,2,3,5,8,13])

19
projects/Day 14/art.py Normal file
View file

@ -0,0 +1,19 @@
logo = """
__ ___ __
/ / / (_)___ _/ /_ ___ _____
/ /_/ / / __ `/ __ \/ _ \/ ___/
/ __ / / /_/ / / / / __/ /
/_/ ///_/\__, /_/ /_/\___/_/
/ / /____/_ _____ _____
/ / / __ \ | /| / / _ \/ ___/
/ /___/ /_/ / |/ |/ / __/ /
/_____/\____/|__/|__/\___/_/
"""
vs = """
_ __
| | / /____
| | / / ___/
| |/ (__ )
|___/____(_)
"""

View file

@ -0,0 +1,302 @@
data = [
{
'name': 'Instagram',
'follower_count': 346,
'description': 'Social media platform',
'country': 'United States'
},
{
'name': 'Cristiano Ronaldo',
'follower_count': 215,
'description': 'Footballer',
'country': 'Portugal'
},
{
'name': 'Ariana Grande',
'follower_count': 183,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': 'Dwayne Johnson',
'follower_count': 181,
'description': 'Actor and professional wrestler',
'country': 'United States'
},
{
'name': 'Selena Gomez',
'follower_count': 174,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': 'Kylie Jenner',
'follower_count': 172,
'description': 'Reality TV personality and businesswoman and Self-Made Billionaire',
'country': 'United States'
},
{
'name': 'Kim Kardashian',
'follower_count': 167,
'description': 'Reality TV personality and businesswoman',
'country': 'United States'
},
{
'name': 'Lionel Messi',
'follower_count': 149,
'description': 'Footballer',
'country': 'Argentina'
},
{
'name': 'Beyoncé',
'follower_count': 145,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'Neymar',
'follower_count': 138,
'description': 'Footballer',
'country': 'Brasil'
},
{
'name': 'National Geographic',
'follower_count': 135,
'description': 'Magazine',
'country': 'United States'
},
{
'name': 'Justin Bieber',
'follower_count': 133,
'description': 'Musician',
'country': 'Canada'
},
{
'name': 'Taylor Swift',
'follower_count': 131,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'Kendall Jenner',
'follower_count': 127,
'description': 'Reality TV personality and Model',
'country': 'United States'
},
{
'name': 'Jennifer Lopez',
'follower_count': 119,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': 'Nicki Minaj',
'follower_count': 113,
'description': 'Musician',
'country': 'Trinidad and Tobago'
},
{
'name': 'Nike',
'follower_count': 109,
'description': 'Sportswear multinational',
'country': 'United States'
},
{
'name': 'Khloé Kardashian',
'follower_count': 108,
'description': 'Reality TV personality and businesswoman',
'country': 'United States'
},
{
'name': 'Miley Cyrus',
'follower_count': 107,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': 'Katy Perry',
'follower_count': 94,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'Kourtney Kardashian',
'follower_count': 90,
'description': 'Reality TV personality',
'country': 'United States'
},
{
'name': 'Kevin Hart',
'follower_count': 89,
'description': 'Comedian and actor',
'country': 'United States'
},
{
'name': 'Ellen DeGeneres',
'follower_count': 87,
'description': 'Comedian',
'country': 'United States'
},
{
'name': 'Real Madrid CF',
'follower_count': 86,
'description': 'Football club',
'country': 'Spain'
},
{
'name': 'FC Barcelona',
'follower_count': 85,
'description': 'Football club',
'country': 'Spain'
},
{
'name': 'Rihanna',
'follower_count': 81,
'description': 'Musician and businesswoman',
'country': 'Barbados'
},
{
'name': 'Demi Lovato',
'follower_count': 80,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': "Victoria's Secret",
'follower_count': 69,
'description': 'Lingerie brand',
'country': 'United States'
},
{
'name': 'Zendaya',
'follower_count': 68,
'description': 'Actress and musician',
'country': 'United States'
},
{
'name': 'Shakira',
'follower_count': 66,
'description': 'Musician',
'country': 'Colombia'
},
{
'name': 'Drake',
'follower_count': 65,
'description': 'Musician',
'country': 'Canada'
},
{
'name': 'Chris Brown',
'follower_count': 64,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'LeBron James',
'follower_count': 63,
'description': 'Basketball player',
'country': 'United States'
},
{
'name': 'Vin Diesel',
'follower_count': 62,
'description': 'Actor',
'country': 'United States'
},
{
'name': 'Cardi B',
'follower_count': 67,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'David Beckham',
'follower_count': 82,
'description': 'Footballer',
'country': 'United Kingdom'
},
{
'name': 'Billie Eilish',
'follower_count': 61,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'Justin Timberlake',
'follower_count': 59,
'description': 'Musician and actor',
'country': 'United States'
},
{
'name': 'UEFA Champions League',
'follower_count': 58,
'description': 'Club football competition',
'country': 'Europe'
},
{
'name': 'NASA',
'follower_count': 56,
'description': 'Space agency',
'country': 'United States'
},
{
'name': 'Emma Watson',
'follower_count': 56,
'description': 'Actress',
'country': 'United Kingdom'
},
{
'name': 'Shawn Mendes',
'follower_count': 57,
'description': 'Musician',
'country': 'Canada'
},
{
'name': 'Virat Kohli',
'follower_count': 55,
'description': 'Cricketer',
'country': 'India'
},
{
'name': 'Gigi Hadid',
'follower_count': 54,
'description': 'Model',
'country': 'United States'
},
{
'name': 'Priyanka Chopra Jonas',
'follower_count': 53,
'description': 'Actress and musician',
'country': 'India'
},
{
'name': '9GAG',
'follower_count': 52,
'description': 'Social media platform',
'country': 'China'
},
{
'name': 'Ronaldinho',
'follower_count': 51,
'description': 'Footballer',
'country': 'Brasil'
},
{
'name': 'Maluma',
'follower_count': 50,
'description': 'Musician',
'country': 'Colombia'
},
{
'name': 'Camila Cabello',
'follower_count': 49,
'description': 'Musician',
'country': 'Cuba'
},
{
'name': 'NBA',
'follower_count': 47,
'description': 'Club Basketball Competition',
'country': 'United States'
}
]

51
projects/Day 14/main.py Normal file
View file

@ -0,0 +1,51 @@
# imports
import replit
import random
import art
from game_data import data
# get new people
def load_people():
a = random.choice(data)
b = random.choice(data)
while (b == a):
b = random.choice(data)
return a, b
# play game
def play():
# setup variables
score = 0
is_start = True
lost_game = False
while True:
replit.clear()
print(art.logo)
if is_start == False:
print(f"You're right! Current score: {score}.")
a, b = load_people()
print(f"Compare A: {a['name']}, a {a['description']}, from {a['country']}")
print(art.vs)
print(f"Compare B: {b['name']}, a {b['description']}, from {b['country']}")
answer = input("Who has more followers? Type 'A' or 'B': ")
# check answer
if a['follower_count'] > b['follower_count'] and answer == "A":
score += 1
is_start = False
continue
elif a['follower_count'] > b['follower_count'] and answer == "B":
break
elif a['follower_count'] < b['follower_count'] and answer == "A":
break
else:
score += 1
is_start = False
continue
print(f"Sorry, that's wrong. Final score: {score}")
# run game
play()

31
projects/Day 15/data.py Normal file
View file

@ -0,0 +1,31 @@
menu = {
"espresso": {
"ingredients": {
"water": 50,
"coffee": 18,
},
"cost": 1.5,
},
"latte": {
"ingredients": {
"water": 200,
"milk": 150,
"coffee": 24,
},
"cost": 2.5,
},
"cappuccino": {
"ingredients": {
"water": 250,
"milk": 100,
"coffee": 24,
},
"cost": 3.0,
}
}
resources = {
"water": 300,
"milk": 200,
"coffee": 100,
}

49
projects/Day 15/main.py Normal file
View file

@ -0,0 +1,49 @@
# imports
from data import menu, resources
# coffee machine logic
def coffee_machine():
response = ""
profit = 0.00
water_left = resources['water']
milk_left = resources['milk']
coffee_left = resources['coffee']
while response != "off":
money = 0.00
response = input("What would you like? (espresso/latte/cappuccino): ")
if response == "report":
print(f"Water: {water_left}ml")
print(f"Milk: {milk_left}ml")
print(f"Coffee: {coffee_left}g")
print(f"Profit: ${profit}")
elif response == "espresso" or response == "latte" or response == "cappuccino":
cost = menu[response]['cost']
for ingredient in menu[response]['ingredients']:
if resources[ingredient] < menu[response]['ingredients'][ingredient]:
print(f"Sorry there is not enough {ingredient}.")
continue
print("Please insert coins.")
quarters = float(input("How many quarters?: "))
dimes = float(input("How many dimes?: "))
nickles = float(input("How many nickles?: "))
pennies = float(input("How many pennies?: "))
money += 0.25*quarters + 0.10*dimes + 0.05*nickles + 0.01*pennies
if money < cost:
print("Sorry that's not enough money. Money refunded.")
continue
profit += cost
water_left -= menu[response]['ingredients']['water']
coffee_left -= menu[response]['ingredients']['coffee']
if 'milk' in menu[response]['ingredients']:
milk_left -= menu[response]['ingredients']['milk']
money -= cost
print(f"Here is ${money} in change.")
print(f"Here is your {response} ☕. Enjoy!")
elif response == "off":
break
else:
print("Please select a valid item.")
exit()
# start coffee machine
coffee_machine()

View file

@ -0,0 +1,6 @@
# Day 16 - Learning OOP with Python
- OOP concepts were taught in the source main.py file, such as classes, attributes, and methods. The Turtle and prettytable packages were also used to explore these concepts, and I installed prettytable in a virtual environment for this.
- The main objective of today is to simulate a coffee machine using OOP in the oop-coffee-machine folder. The coffee_maker.py, menu.py, and money_machine.py were given as abstract modules to work from in order to understand OOP.
![Day_16_OOP_Coffee_Machine](https://user-images.githubusercontent.com/30333942/128575429-7173d86e-7ae5-4bf0-909a-34e6e37dfc70.gif)

View file

@ -0,0 +1 @@
another_variable = 12

21
projects/Day 16/main.py Normal file
View file

@ -0,0 +1,21 @@
# from another_module import another_variable
# print(another_variable)
# from turtle import Turtle, Screen
# buddy = Turtle() # creating class object
# print(buddy)
# buddy.shape("turtle") # calling class methods
# buddy.color("blue")
# buddy.forward(100)
# my_screen = Screen()
# print(my_screen.canvheight) # getting class attribute
# my_screen.exitonclick()
from prettytable import PrettyTable
table = PrettyTable()
table.add_column("Pokemon Name", ["Pikachu", "Squirtle", "Charmander"])
table.add_column("Type", ["Electric", "Water", "Fire"])
table.align = "l"
print(table)

View file

@ -0,0 +1,29 @@
class CoffeeMaker:
"""Models the machine that makes the coffee"""
def __init__(self):
self.resources = {
"water": 300,
"milk": 200,
"coffee": 100,
}
def report(self):
"""Prints a report of all resources."""
print(f"Water: {self.resources['water']}ml")
print(f"Milk: {self.resources['milk']}ml")
print(f"Coffee: {self.resources['coffee']}g")
def is_resource_sufficient(self, drink):
"""Returns True when order can be made, False if ingredients are insufficient."""
can_make = True
for item in drink.ingredients:
if drink.ingredients[item] > self.resources[item]:
print(f"Sorry there is not enough {item}.")
can_make = False
return can_make
def make_coffee(self, order):
"""Deducts the required ingredients from the resources."""
for item in order.ingredients:
self.resources[item] -= order.ingredients[item]
print(f"Here is your {order.name} ☕️. Enjoy!")

View file

@ -0,0 +1,28 @@
from menu import Menu, MenuItem
from coffee_maker import CoffeeMaker
from money_machine import MoneyMachine
# Instantiating objects from imported classes
my_coffee_menu = Menu()
my_coffee_maker = CoffeeMaker()
my_money_machine = MoneyMachine()
# Begin coffee machine with OOP!
response = ""
while response != "off":
menu_items = my_coffee_menu.get_items()
response = input(f"What would you like? ({menu_items}): ")
if response == "off":
break
elif response == "report":
my_coffee_maker.report()
my_money_machine.report()
else:
drink = my_coffee_menu.find_drink(response)
drink_cost = drink.cost
if not my_coffee_maker.is_resource_sufficient(drink):
print(f"Sorry there is not enough ingredients for {response}.")
continue
if not my_money_machine.make_payment(drink_cost):
continue
my_coffee_maker.make_coffee(drink)

View file

@ -0,0 +1,34 @@
class MenuItem:
"""Models each Menu Item."""
def __init__(self, name, water, milk, coffee, cost):
self.name = name
self.cost = cost
self.ingredients = {
"water": water,
"milk": milk,
"coffee": coffee
}
class Menu:
"""Models the Menu with drinks."""
def __init__(self):
self.menu = [
MenuItem(name="latte", water=200, milk=150, coffee=24, cost=2.5),
MenuItem(name="espresso", water=50, milk=0, coffee=18, cost=1.5),
MenuItem(name="cappuccino", water=250, milk=50, coffee=24, cost=3),
]
def get_items(self):
"""Returns all the names of the available menu items"""
options = ""
for item in self.menu:
options += f"{item.name}/"
return options
def find_drink(self, order_name):
"""Searches the menu for a particular drink by name. Returns that item if it exists, otherwise returns None"""
for item in self.menu:
if item.name == order_name:
return item
print("Sorry that item is not available.")

View file

@ -0,0 +1,39 @@
class MoneyMachine:
CURRENCY = "$"
COIN_VALUES = {
"quarters": 0.25,
"dimes": 0.10,
"nickles": 0.05,
"pennies": 0.01
}
def __init__(self):
self.profit = 0
self.money_received = 0
def report(self):
"""Prints the current profit"""
print(f"Money: {self.CURRENCY}{self.profit}")
def process_coins(self):
"""Returns the total calculated from coins inserted."""
print("Please insert coins.")
for coin in self.COIN_VALUES:
self.money_received += int(input(f"How many {coin}?: ")) * self.COIN_VALUES[coin]
return self.money_received
def make_payment(self, cost):
"""Returns True when payment is accepted, or False if insufficient."""
self.process_coins()
if self.money_received >= cost:
change = round(self.money_received - cost, 2)
print(f"Here is {self.CURRENCY}{change} in change.")
self.profit += cost
self.money_received = 0
return True
else:
print("Sorry that's not enough money. Money refunded.")
self.money_received = 0
return False

View file

@ -0,0 +1,6 @@
# Day 17 - Implementing Classes
- Learned the structure of creating a class with its attributes, methods, and how to initialize objects
- Created a trivia quiz game, with some neat questions from [opentdb](https://opentdb.com/).
![Day_17_Trivia](https://user-images.githubusercontent.com/30333942/128618891-34c051c8-b0fe-4982-8852-536a3a9bf311.gif)

View file

@ -0,0 +1,22 @@
class User:
def __init__(self, user_id, username):
self.id = user_id
self.username = username
self.followers = 0
self.following = 0
def follow(self, user):
user.followers += 1
self.following += 1
user_1 = User("001", "mueez")
# user_1.id = "001" # like self.id in init function, but just for this user_1 object if not in init
# user_1.username = "mueez"
user_2 = User("002", "another_user")
user_1.follow(user_2)
print(user_1.followers)
print(user_2.followers)
print(user_1.following)
print(user_2.following)

View file

@ -0,0 +1,82 @@
question_data = [
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "Linus Torvalds created Linux and Git.",
"correct_answer": "True",
"incorrect_answers": ["False"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "The programming language Python is based off a modified version of JavaScript.",
"correct_answer": "False",
"incorrect_answers": ["True"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "The logo for Snapchat is a Bell.",
"correct_answer": "False",
"incorrect_answers": ["True"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "RAM stands for Random Access Memory.",
"correct_answer": "True",
"incorrect_answers": ["False"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "Ada Lovelace is often considered the first computer programmer.",
"correct_answer": "True",
"incorrect_answers": ["False"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "In most programming languages, the operator ++ is equivalent to the statement += 1.",
"correct_answer": "True",
"incorrect_answers": ["False"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "The Windows 7 operating system has six main editions.",
"correct_answer": "True",
"incorrect_answers": ["False"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "The NVidia GTX 1080 gets its name because it can only render at a 1920x1080 screen resolution.",
"correct_answer": "False",
"incorrect_answers": ["True"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "Linux was first created as an alternative to Windows XP.",
"correct_answer": "False",
"incorrect_answers": ["True"],
},
{
"category": "Science: Computers",
"type": "boolean",
"difficulty": "easy",
"question": "The Python programming language gets its name from the British comedy group Monty Python.",
"correct_answer": "True",
"incorrect_answers": ["False"],
},
]

View file

@ -0,0 +1,17 @@
from question_model import Question
from data import question_data
from quiz_brain import QuizBrain
question_bank = []
for question in question_data:
question_text = question["question"]
question_answer = question["correct_answer"]
new_question = Question(question_text, question_answer)
question_bank.append(new_question)
quiz = QuizBrain(question_bank)
while quiz.still_has_questions():
quiz.next_question()
print("You've completed the quiz!")
print(f"Your final score was: {quiz.score}/{len(quiz.question_list)}.")

View file

@ -0,0 +1,4 @@
class Question:
def __init__(self, text, answer):
self.text = text
self.answer = answer

View file

@ -0,0 +1,25 @@
class QuizBrain:
def __init__(self, question_list):
self.question_number = 0
self.question_list = question_list
self.score = 0
def still_has_questions(self):
return self.question_number < len(self.question_list)
def next_question(self):
current_question = self.question_list[self.question_number]
self.question_number += 1
user_answer = input(
f"Q.{self.question_number}: {current_question.text} (True/False)?: "
)
self.check_answer(user_answer, current_question.answer)
def check_answer(self, user_answer, correct_answer):
if user_answer.lower() == correct_answer.lower():
self.score += 1
print("You got it right!")
else:
print("That's wrong.")
print(f"The correct answer was: {correct_answer}.")
print(f"Your current score is: {self.score}/{self.question_number}.\n")

29
projects/Day 18/README.md Normal file
View file

@ -0,0 +1,29 @@
# Day 18 - Turtle & the Graphical User Interface (GUI)
- Developed various basic turtle graphics.
- Spirograph, random walk, various polygons, dashed line, and square.
- Formed a dot art based on Hirst artwork.
## Dot art
![Day_18_Dot_Art](https://user-images.githubusercontent.com/30333942/128644328-9128d1b2-e416-4daf-ba05-cc37c2cff9ee.gif)
## Spirograph
![Day_18_Spirograph](https://user-images.githubusercontent.com/30333942/128644332-0aad8f64-5d71-4579-9c53-07333bb38233.gif)
## Random Walk
![Day_18_Random_Walk](https://user-images.githubusercontent.com/30333942/128644335-00899537-04b9-4f88-bcd6-46b7590082fe.gif)
## Polygons
![Day_18_Polygons](https://user-images.githubusercontent.com/30333942/128644338-23011edc-6246-49c2-9574-0f5e0497bcb6.gif)
## Dashed Line
![Day_18_Dashed_Line](https://user-images.githubusercontent.com/30333942/128644340-dff27a27-a6e1-44d3-95c0-9f885f9771b2.gif)
## Square
![Day_18_Square](https://user-images.githubusercontent.com/30333942/128644342-746c14cf-86f2-47c0-ae93-b3df1bf32b13.gif)

View file

@ -0,0 +1,66 @@
from turtle import Turtle, Screen, colormode
from random import randint, choice
arrow = Turtle()
# Draw a square
def square():
for i in range(4):
arrow.forward(100)
arrow.right(90)
# square()
# Draw a dashed line
def dashed_line():
for i in range(20):
arrow.forward(10)
arrow.penup()
arrow.forward(10)
arrow.pendown()
# dashed_line()
# Draw a triangle, square, pentagon, hexagon, heptagon, octagon, nonagon, and decagon
def polygons():
colormode(255)
for i in range(3, 11):
angle = 360 / i
color = (randint(0, 255), randint(0, 255), randint(0, 255))
arrow.color(color)
for j in range(1, i + 1):
arrow.right(angle)
arrow.forward(100)
# polygons()
# Random Walk (thickness, speed up turtle)
def random_walk(steps):
colormode(255)
arrow.pensize(15)
arrow.speed(0)
for i in range(steps):
color = (randint(0, 255), randint(0, 255), randint(0, 255))
arrow.color(color)
step_size = randint(0, 50)
arrow.setheading(choice([0, 90, 180, 270]))
arrow.forward(step_size)
# random_walk(1000)
# Spirograph
def spirograph():
colormode(255)
arrow.speed(0)
heading = 0
for i in range(72):
color = (randint(0, 255), randint(0, 255), randint(0, 255))
arrow.color(color)
arrow.circle(200)
arrow.setheading(heading)
heading += 5
# spirograph()
screen = Screen()
screen.exitonclick()

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View file

@ -0,0 +1,72 @@
# # Get color palette from an image
# import colorgram
# color_list = []
# colors = colorgram.extract('colors_source.jpg', 30)
# for color in colors:
# r = color.rgb.r
# g = color.rgb.g
# b = color.rgb.b
# new_color = (r, g, b)
# color_list.append(new_color)
# print(color_list)
from turtle import Turtle, Screen, colormode
import random
arrow = Turtle()
color_list = [
(221, 144, 96),
(165, 57, 88),
(68, 84, 153),
(100, 167, 208),
(154, 66, 54),
(109, 176, 128),
(195, 76, 113),
(209, 123, 155),
(222, 90, 66),
(233, 163, 188),
(238, 223, 97),
(107, 117, 187),
(176, 184, 224),
(141, 210, 221),
(84, 95, 88),
(163, 139, 49),
(58, 173, 186),
(67, 54, 96),
(234, 171, 155),
(166, 206, 188),
(154, 35, 49),
(91, 159, 124),
(189, 27, 24),
(65, 55, 64),
(56, 49, 71),
(71, 56, 49),
]
# Set arrow starting position
arrow.hideturtle()
arrow.speed(0)
arrow.penup()
arrow.sety(-250)
arrow.setx(-250)
arrow.width(20)
# Create dots
colormode(255)
number_of_dots = 100
for i in range(1, number_of_dots + 1):
arrow.pendown()
arrow.dot(20, random.choice(color_list))
arrow.penup()
arrow.forward(50)
if i % 10 == 0:
arrow.penup()
arrow.backward(500)
arrow.left(90)
arrow.forward(50)
arrow.right(90)
screen = Screen()
screen.exitonclick()

21
projects/Day 19/README.md Normal file
View file

@ -0,0 +1,21 @@
# Day 19 - Instances, State, and Higher Order Functions
- Built an etch-a-sketch while understanding higher order functions
- Simulated a turtle race with randomized steps using class instances
## Etch-a-Sketch
![Day_19_Etch_A_Sketch](https://user-images.githubusercontent.com/30333942/128927402-10006522-2640-4569-b6d0-706cca4fc811.gif)
This etch-a-sketch uses higher order functions to run when keys are pressed on the keyboard.
- **w** - Move forwards
- **s** - Move backwards
- **a** - Turn left
- **d** - Turn right
- **c** - Reset etch-a-sketch
## The Great Turtle Race
![Day_19_The_Great_Turtle_Race](https://user-images.githubusercontent.com/30333942/128927073-cf125780-b3ce-432e-8808-c4ac4d2c6e34.gif)
The Great Turtle Race uses multiple instances of the Turtle object from [the turtle module](https://docs.python.org/3/library/turtle.html) that move by a random number of steps to the edge of the screen.

View file

@ -0,0 +1,27 @@
from turtle import Turtle, Screen
arrow = Turtle()
screen = Screen()
def move_forwards():
arrow.forward(10)
def move_backwards():
arrow.backward(10)
def clockwise():
arrow.right(10)
def counter_clockwise():
arrow.left(10)
def clear_drawing():
arrow.reset()
screen.listen()
screen.onkey(key="w", fun=move_forwards) # higher order function
screen.onkey(key="s", fun=move_backwards)
screen.onkey(key="d", fun=clockwise)
screen.onkey(key="a", fun=counter_clockwise)
screen.onkey(key="c", fun=clear_drawing)
screen.exitonclick()

View file

@ -0,0 +1,43 @@
from turtle import Turtle, Screen
import random
# Game settings
is_race_on = False
screen = Screen()
screen.title("The Great Turtle Race!")
screen.setup(width=500, height=400)
# Get user guess
user_selection = ""
while not user_selection:
user_selection = screen.textinput(title="Who will win?", prompt="Which turtle will win the race?\nType blue, green, red, orange, turquoise, or purple.\nEnter a color: ")
# Setup turtle objects after input
colors = ["blue", "green", "turquoise", "orange", "red", "purple"]
turtles = [Turtle(shape="turtle") for turtle in range(6)]
for i in range(6):
turtles[i].color(colors[i])
turtles[i].penup()
turtles[i].goto(x=-230, y=-100+(i*40))
# Start race!
result = Turtle()
result.penup()
result.hideturtle()
result.goto(x=0, y=100)
is_race_on = True
while is_race_on:
for turtle in turtles:
# Move turtle forward a random distance
rand_distance = random.randint(0, 10)
turtle.forward(rand_distance)
# Check if a turtle won the race
if turtle.xcor() > 230:
is_race_on = False
winning_color = turtle.pencolor()
if winning_color == user_selection:
result.write(f"You've won! The {winning_color} turtle is the winner!", align="center", font=("Open Sans", 16, "normal"))
else:
result.write(f"You've lost! The {winning_color} turtle is the winner!", align="center", font=("Open Sans", 16, "normal"))
screen.exitonclick()

View file

@ -0,0 +1,13 @@
#If the bill was $150.00, split between 5 people, with 12% tip.
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60
#Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪
#HINT 1: https://www.google.com/search?q=how+to+round+number+to+2+decimal+places+python&oq=how+to+round+number+to+2+decimal
#HINT 2: https://www.kite.com/python/answers/how-to-limit-a-float-to-two-decimal-places-in-python
print("Welcome to the tip calculator!")
total_bill = float(input("What was the total bill? $"))
percent_tip = int(input("What percentage tip would you like to give? 10, 12, or 15? "))
total_people = int(input("How many people to split the bill? "))
bill_with_tip = total_bill + (total_bill * (percent_tip / 100))
cost_per_person = round(bill_with_tip / total_people, 2)
print(f"Each person should pay: ${cost_per_person}")

View file

@ -0,0 +1,8 @@
# Day 20 - Build the Snake Game Part 1: Animation & Coordinates
- Made a controllable snake, and will complete the full snake game on Day 21.
- Abstracted snake logic into a Snake class.
## Snake
![Day_20_Snake](https://user-images.githubusercontent.com/30333942/129074881-fff5a265-a4a7-445c-93bc-fc6553c50166.gif)

26
projects/Day 20/main.py Normal file
View file

@ -0,0 +1,26 @@
from turtle import Screen
from snake import Snake
import time
screen = Screen()
screen.setup(width=600, height=600)
screen.bgcolor("black")
screen.title("A Snake Game!")
screen.tracer(0)
snake = Snake()
screen.listen()
screen.onkey(snake.up, "Up")
screen.onkey(snake.down, "Down")
screen.onkey(snake.left, "Left")
screen.onkey(snake.right, "Right")
game_is_on = True
while game_is_on:
screen.update()
time.sleep(0.1)
snake.move()
screen.exitonclick()

45
projects/Day 20/snake.py Normal file
View file

@ -0,0 +1,45 @@
from turtle import Turtle
STARTING_POSITIONS = [(0, 0), (-20, 0), (-40, 0)]
MOVE_DISTANCE = 20
UP = 90
DOWN = 270
LEFT = 180
RIGHT = 0
class Snake:
def __init__(self):
self.segments = []
self.create_snake()
self.head = self.segments[0]
def create_snake(self):
for position in STARTING_POSITIONS:
segment = Turtle(shape="square")
segment.color("white")
segment.penup()
segment.goto(position)
self.segments.append(segment)
def move(self):
for segment_index in range(len(self.segments) - 1, 0, -1):
new_x = self.segments[segment_index - 1].xcor()
new_y = self.segments[segment_index - 1].ycor()
self.segments[segment_index].goto(new_x, new_y)
self.head.forward(MOVE_DISTANCE)
def up(self):
if self.head.heading() != DOWN:
self.head.setheading(90)
def down(self):
if self.head.heading() != UP:
self.head.setheading(270)
def left(self):
if self.head.heading() != RIGHT:
self.head.setheading(180)
def right(self):
if self.head.heading() != LEFT:
self.head.setheading(0)

15
projects/Day 21/README.md Normal file
View file

@ -0,0 +1,15 @@
# Day 21 - Build the Snake Game Part 2: Inheritance & List Slicing
- Built a snake game.
- Learned about class inheritance and list slicing.
```python
# The Fish class inherits the attributes and methods of the Animal class
class Fish(Animal):
def __init__(self):
super().__init__()
```
## Snake Game
![Day_21_Snake_Game](https://user-images.githubusercontent.com/30333942/129274809-8c292e1e-28e4-4df5-a1b0-57b77155782a.gif)

18
projects/Day 21/food.py Normal file
View file

@ -0,0 +1,18 @@
from turtle import Turtle
import random
class Food(Turtle):
def __init__(self):
super().__init__()
self.shape("circle")
self.penup()
self.shapesize(stretch_len=0.5, stretch_wid=0.5)
self.color("red")
self.speed("fastest")
self.refresh()
def refresh(self):
random_x = random.randint(-280, 280)
random_y = random.randint(-280, 255)
self.goto(random_x, random_y)

51
projects/Day 21/main.py Normal file
View file

@ -0,0 +1,51 @@
from turtle import Screen
from snake import Snake
from food import Food
from scoreboard import Scoreboard
import time
screen = Screen()
screen.setup(width=600, height=600)
screen.bgcolor("black")
screen.title("A Snake Game!")
screen.tracer(0)
snake = Snake()
food = Food()
scoreboard = Scoreboard()
screen.listen()
screen.onkey(snake.up, "Up")
screen.onkey(snake.down, "Down")
screen.onkey(snake.left, "Left")
screen.onkey(snake.right, "Right")
game_is_on = True
while game_is_on:
screen.update()
time.sleep(0.075)
snake.move()
# Food collision
if snake.head.distance(food) < 15:
food.refresh()
snake.extend()
scoreboard.increase_score()
# Wall collision
if (
snake.head.xcor() > 280
or snake.head.xcor() < -280
or snake.head.ycor() > 290
or snake.head.ycor() < -280
):
scoreboard.game_over()
game_is_on = False
# Tail collision
for segment in snake.segments[1:]:
if snake.head.distance(segment) < 10:
scoreboard.game_over()
game_is_on = False
screen.exitonclick()

View file

@ -0,0 +1,28 @@
from turtle import Turtle
ALIGNMENT = "center"
FONT = ("Open Sans", 16, "normal")
class Scoreboard(Turtle):
def __init__(self):
super().__init__()
self.score = 0
self.penup()
self.hideturtle()
self.goto(x=0, y=260)
self.color("white")
self.update_scoreboard()
def update_scoreboard(self):
self.write(f"Score: {self.score}", align=ALIGNMENT, font=FONT)
def increase_score(self):
self.score += 1
self.clear()
self.update_scoreboard()
def game_over(self):
self.goto(x=0, y=0)
self.color("red")
self.write("GAME OVER", align=ALIGNMENT, font=FONT)

53
projects/Day 21/snake.py Normal file
View file

@ -0,0 +1,53 @@
from turtle import Turtle
STARTING_POSITIONS = [(0, 0), (-20, 0), (-40, 0)]
MOVE_DISTANCE = 20
UP = 90
DOWN = 270
LEFT = 180
RIGHT = 0
class Snake:
def __init__(self):
self.segments = []
self.create_snake()
self.head = self.segments[0]
def create_snake(self):
for position in STARTING_POSITIONS:
self.add_segment(position)
def add_segment(self, position):
segment = Turtle(shape="square")
segment.color("white")
segment.penup()
segment.goto(position)
self.segments.append(segment)
def extend(self):
# Add a new segment to the snake.
self.add_segment(self.segments[-1].position())
def move(self):
for segment_index in range(len(self.segments) - 1, 0, -1):
new_x = self.segments[segment_index - 1].xcor()
new_y = self.segments[segment_index - 1].ycor()
self.segments[segment_index].goto(new_x, new_y)
self.head.forward(MOVE_DISTANCE)
def up(self):
if self.head.heading() != DOWN:
self.head.setheading(90)
def down(self):
if self.head.heading() != UP:
self.head.setheading(270)
def left(self):
if self.head.heading() != RIGHT:
self.head.setheading(180)
def right(self):
if self.head.heading() != LEFT:
self.head.setheading(0)

View file

@ -0,0 +1,45 @@
print('''
*******************************************************************************
_.-.
/ 99\
( `\
|| , ,|
__ | v_____/
,.--"`-.". / `---'
_.-' '-/ |
_.-" | '-. |_/_
,__.-' _,.--\ \ (( /-\
',_..--' `\ \ ((_ /
`-, ) |('
| |-.,,-" (
| | `\ `',_
) \ \,(\(\-'
\ `-,_
\_(\-(\`-`
*******************************************************************************
''')
print("Welcome to ~Shama's ARK Escape~.\n")
print("Your mission is to get home from the woods without getting caught by dinosaurs.\nThen stop playing and go eat dinner with your family.\n\nThey miss you.\n")
loud_noise = input("You're in the woods heading home while rocking some prehistoric Heelys.\nYou hear a loud roar up ahead.\nDo you go towards it?\nYes or no: ")
if loud_noise.lower() == "no":
print("You die by playing without risks.\nGame Over.")
elif loud_noise.lower() == "yes":
dino = input("\nYou go towards the noise.\nIt's a dinosaur! AAAAAAA\nDo you run or hide? ")
if dino.lower() == "run":
print("\nThe dinosaur spots you running and chases.\nYou get gobbled like a turkey.\nGame Over.")
elif dino.lower() == "hide":
path = input("\nThe dinosaur walks away while you hide behind bushes.\nYou see your house in the distance!\nYou start walking towards it but there's three paths left to your house.\nThe left path is filled with tall grass.\nThe right path has another house in the distance you haven't seen before.\nThere's also a Decepticon that just rolled out in front of your home.\nDo you go left, right, or skrt past the Decepticon with your prehistoric Heelys?\nLeft, right, or skrt: ")
if path.lower() == "left":
print("\nYou walk through the tall grass.\nYou're almost to the end when suddenly, you open a patch of grass to a T-Rex!\nGame Over.")
elif path.lower() == "right":
print("\nYou walk over to the random house you haven't seen before.\nYou open the door without knocking, which was a bad move!\nYou woke up May in her own home!\nMay chases you out of her home and feeds you to her pet dinosaur you hid from earlier.\nGG, May wins.")
elif path.lower() == "skrt":
print("\nYou skrt past the Decepticon like a G.\nThey can't keep up because you're too slick with it when wearing prehistoric Heelys.\nYou made it home!\nYou save your game and close it, finally ready to go eat dinner with your family. :)\nGG!")
else:
print("Your input is invalid. Did you type something wrong?")
else:
print("Your input is invalid. Did you type something wrong?")
else:
print("Your input is invalid. Did you type something wrong?")
#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

View file

@ -0,0 +1,55 @@
import random
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
print("Welcome to the Rock Paper Scissors tournament!")
user = input("What do you choose? Type 0 for Rock, 1 for Paper, or 2 for Scissors.\n")
user = int(user)
cpu = random.randint(0, 2)
rock_num = 0
paper_num = 1
scissors_num = 2
if user == rock_num and cpu == paper_num:
print(f"{rock}\nComputer chose paper:\n{paper}\nYou lose.")
elif user == rock_num and cpu == scissors_num:
print(f"{rock}\nComputer chose scissors:\n{scissors}\nYou win!")
elif user == rock_num and cpu == rock_num:
print(f"{rock}\nComputer chose rock:\n{rock}\nDraw.")
elif user == paper_num and cpu == rock_num:
print(f"{paper}\nComputer chose rock:\n{rock}\nYou win!")
elif user == paper_num and cpu == scissors_num:
print(f"{paper}\nComputer chose scissors:\n{scissors}\nYou lose.")
elif user == paper_num and cpu == paper_num:
print(f"{paper}\nComputer chose paper:\n{paper}\nDraw.")
elif user == scissors_num and cpu == rock_num:
print(f"{scissors}\nComputer chose rock:\n{rock}\nYou lose.")
elif user == scissors_num and cpu == paper_num:
print(f"{scissors}\nComputer chose paper:\n{paper}\nYou win!")
elif user == scissors_num and cpu == scissors_num:
print(f"{scissors}\nComputer chose scissors:\n{scissors}\nDraw.")

View file

@ -0,0 +1,33 @@
#Password Generator Project
import random
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']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
print("Welcome to the PyPassword Generator!")
nr_letters= int(input("How many letters would you like in your password?\n"))
nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))
#Eazy Level - Order not randomised:
#e.g. 4 letter, 2 symbol, 2 number = JduE&!91
password = ""
for aletter in range(1, nr_letters+1):
password += random.choice(letters)
for asymbol in range(1, nr_symbols+1):
password += random.choice(symbols)
for anumber in range(1, nr_numbers+1):
password += random.choice(numbers)
# print(password)
#Hard Level - Order of characters randomised:
#e.g. 4 letter, 2 symbol, 2 number = g^2jk8&P
listpass = list(password)
random.shuffle(listpass)
# newlistpass = random.sample(listpass, len(listpass))
finalpass = ""
for letter in listpass:
finalpass += letter
print(finalpass)

View file

@ -0,0 +1,17 @@
def turn_right():
turn_left()
turn_left()
turn_left()
while front_is_clear():
move()
turn_left()
while not at_goal():
if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()

View file

@ -0,0 +1,69 @@
stages = ['''
+---+
| |
O |
/|\ |
/ \ |
|
=========
''', '''
+---+
| |
O |
/|\ |
/ |
|
=========
''', '''
+---+
| |
O |
/|\ |
|
|
=========
''', '''
+---+
| |
O |
/| |
|
|
=========''', '''
+---+
| |
O |
| |
|
|
=========
''', '''
+---+
| |
O |
|
|
|
=========
''', '''
+---+
| |
|
|
|
|
=========
''']
logo = '''
_
| |
| |__ __ _ _ __ __ _ _ __ ___ __ _ _ __
| '_ \ / _` | '_ \ / _` | '_ ` _ \ / _` | '_ \
| | | | (_| | | | | (_| | | | | | | (_| | | | |
|_| |_|\__,_|_| |_|\__, |_| |_| |_|\__,_|_| |_|
__/ |
|___/ '''

View file

@ -0,0 +1,215 @@
word_list = [
'abruptly',
'absurd',
'abyss',
'affix',
'askew',
'avenue',
'awkward',
'axiom',
'azure',
'bagpipes',
'bandwagon',
'banjo',
'bayou',
'beekeeper',
'bikini',
'blitz',
'blizzard',
'boggle',
'bookworm',
'boxcar',
'boxful',
'buckaroo',
'buffalo',
'buffoon',
'buxom',
'buzzard',
'buzzing',
'buzzwords',
'caliph',
'cobweb',
'cockiness',
'croquet',
'crypt',
'curacao',
'cycle',
'daiquiri',
'dirndl',
'disavow',
'dizzying',
'duplex',
'dwarves',
'embezzle',
'equip',
'espionage',
'euouae',
'exodus',
'faking',
'fishhook',
'fixable',
'fjord',
'flapjack',
'flopping',
'fluffiness',
'flyby',
'foxglove',
'frazzled',
'frizzled',
'fuchsia',
'funny',
'gabby',
'galaxy',
'galvanize',
'gazebo',
'giaour',
'gizmo',
'glowworm',
'glyph',
'gnarly',
'gnostic',
'gossip',
'grogginess',
'haiku',
'haphazard',
'hyphen',
'iatrogenic',
'icebox',
'injury',
'ivory',
'ivy',
'jackpot',
'jaundice',
'jawbreaker',
'jaywalk',
'jazziest',
'jazzy',
'jelly',
'jigsaw',
'jinx',
'jiujitsu',
'jockey',
'jogging',
'joking',
'jovial',
'joyful',
'juicy',
'jukebox',
'jumbo',
'kayak',
'kazoo',
'keyhole',
'khaki',
'kilobyte',
'kiosk',
'kitsch',
'kiwifruit',
'klutz',
'knapsack',
'larynx',
'lengths',
'lucky',
'luxury',
'lymph',
'marquis',
'matrix',
'megahertz',
'microwave',
'mnemonic',
'mystify',
'naphtha',
'nightclub',
'nowadays',
'numbskull',
'nymph',
'onyx',
'ovary',
'oxidize',
'oxygen',
'pajama',
'peekaboo',
'phlegm',
'pixel',
'pizazz',
'pneumonia',
'polka',
'pshaw',
'psyche',
'puppy',
'puzzling',
'quartz',
'queue',
'quips',
'quixotic',
'quiz',
'quizzes',
'quorum',
'razzmatazz',
'rhubarb',
'rhythm',
'rickshaw',
'schnapps',
'scratch',
'shiv',
'snazzy',
'sphinx',
'spritz',
'squawk',
'staff',
'strength',
'strengths',
'stretch',
'stronghold',
'stymied',
'subway',
'swivel',
'syndrome',
'thriftless',
'thumbscrew',
'topaz',
'transcript',
'transgress',
'transplant',
'triphthong',
'twelfth',
'twelfths',
'unknown',
'unworthy',
'unzip',
'uptown',
'vaporize',
'vixen',
'vodka',
'voodoo',
'vortex',
'voyeurism',
'walkway',
'waltz',
'wave',
'wavy',
'waxy',
'wellspring',
'wheezy',
'whiskey',
'whizzing',
'whomever',
'wimpy',
'witchcraft',
'wizard',
'woozy',
'wristwatch',
'wyvern',
'xylophone',
'yachtsman',
'yippee',
'yoked',
'youthful',
'yummy',
'zephyr',
'zigzag',
'zigzagging',
'zilch',
'zipper',
'zodiac',
'zombie',
]

50
projects/Day 7/main.py Normal file
View file

@ -0,0 +1,50 @@
import random
import hangman_words
import hangman_art
word_list = hangman_words.word_list
chosen_word = random.choice(word_list)
word_length = len(chosen_word)
end_of_game = False
lives = 6
print(hangman_art.logo)
print(hangman_art.stages[6])
#Testing code
#Create blanks
display = []
for _ in range(word_length):
display += "_"
print(display)
while not end_of_game:
guess = input("Guess a letter: ").lower()
if guess in display:
print(f"You already guessed the letter {guess}.")
#Check guessed letter
for position in range(word_length):
letter = chosen_word[position]
if letter == guess:
display[position] = letter
if guess not in chosen_word:
print(f"The letter {guess} is not in the hidden word. You lose a life.")
lives -= 1
if lives == 0:
end_of_game = True
print("You lose.")
#Join all the elements in the list and turn it into a String.
print(f"{' '.join(display)}")
#Check if user has got all letters.
if "_" not in display:
end_of_game = True
print("You win.")
print(hangman_art.stages[lives])
print(f"\nThe word was {chosen_word}.")

17
projects/Day 8/art.py Normal file
View file

@ -0,0 +1,17 @@
logo = """
,adPPYba, ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYYba, 8b,dPPYba,
a8" "" "" `Y8 a8P_____88 I8[ "" "" `Y8 88P' "Y8
8b ,adPPPPP88 8PP""""""" `"Y8ba, ,adPPPPP88 88
"8a, ,aa 88, ,88 "8b, ,aa aa ]8I 88, ,88 88
`"Ybbd8"' `"8bbdP"Y8 `"Ybbd8"' `"YbbdP"' `"8bbdP"Y8 88
88 88
"" 88
88
,adPPYba, 88 8b,dPPYba, 88,dPPYba, ,adPPYba, 8b,dPPYba,
a8" "" 88 88P' "8a 88P' "8a a8P_____88 88P' "Y8
8b 88 88 d8 88 88 8PP""""""" 88
"8a, ,aa 88 88b, ,a8" 88 88 "8b, ,aa 88
`"Ybbd8"' 88 88`YbbdP"' 88 88 `"Ybbd8"' 88
88
88
"""

33
projects/Day 8/main.py Normal file
View file

@ -0,0 +1,33 @@
import art
alphabet = ['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']
def caesar(text, shift, direction):
final_text = ""
for letter in text:
if letter in alphabet:
letter_index = alphabet.index(letter)
if direction == "encode":
letter_index += shift
if letter_index >= 26:
letter_index -= 26
elif direction == "decode":
letter_index -= shift
final_text += alphabet[letter_index]
else:
final_text += letter
print(f"Here's the result: {final_text}")
def cipher():
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
caesar(text, shift, direction)
restart = input("Type 'yes' if you want to go again. Otherwise type 'no'.\n")
if restart == "yes":
cipher()
else:
return
print(art.logo)
cipher()

13
projects/Day 9/art.py Normal file
View file

@ -0,0 +1,13 @@
logo = '''
___________
\ /
)_______(
|"""""""|_.-._,.---------.,_.-._
| | | | | | ''-.
| |_| |_ _| |_..-'
|_______| '-' `'---------'` '-'
)"""""""(
/_________\\
.-------------.
/_______________\\
'''

View file

@ -0,0 +1,25 @@
from art import logo
print(logo)
print("Welcome to the secret auction program.")
bid_dict = {}
def new_bid():
name = input("What is your name?: ")
bid = input("What's your bid?: $")
bid = float(bid)
bid_dict[name] = bid
end_check = input("Are there any other bidders? Type 'yes' or 'no'.")
if end_check == "yes":
new_bid()
elif end_check == "no":
highest_bid = bid
highest_bidder = name
for bidder in bid_dict:
if bid_dict[bidder] > highest_bid:
highest_bid = bid_dict[bidder]
highest_bidder = bidder
print(f"The winner is {highest_bidder} with a bid of ${highest_bid}.")
return
new_bid()