diff --git a/#For Loop in Python.py b/#For Loop in Python.py new file mode 100644 index 0000000..3be7f2f --- /dev/null +++ b/#For Loop in Python.py @@ -0,0 +1,104 @@ +#For Loop +fruits = ["apple", "banana", "cherry", "kiwi", "mango"] +for a in fruits: + print(a) + print("I love " + a) + + #Average Height Calcuation +student_heights = input("Input a list of student heights\n").split( ) +for n in range(0,len(student_heights)): + student_heights[n] = int(student_heights[n]) +total_height = 0 +for height in student_heights: + total_height += height +number_of_students = 0 +for student in range(0, len(student_heights)): + number_of_students = student + 1 +average_height = round(total_height / number_of_students) +print(f"The average height is {average_height}") + +#High score exercise +student_scores = input("Input a list of student scores: \n").split() +for n in range(0, len(student_scores)): + student_scores[n] = int(student_scores[n]) +highest_score = 0 +for score in student_scores: + if score > highest_score: + highest_score = score +print(f"The highest score in the class is: {highest_score}") + +#For loop with range +for num in range(1, 21, 5): + print(num) + +#Sum of numbers btw 1 and 100 +total = 0 +for num in range(1, 101): + total += num +print(total) + +#Sum of even numbers btw 1 and 100 +total = 0 +for num in range(0, 101, 2): + total += num +print(total) +#OR +total_x = 0 +for num in range(1, 101): + if num % 2 == 0: + total_x += num +print(total_x) + +#Mini Project +#FizzBuzz Game +#write a program that automatically prints the solution to the FizzBuzz game, for the numbers 1 through 100. +for numbers in range(1, 101): + if numbers % 3 == 0 and numbers % 5 == 0: + print("FizzBuzz") + elif numbers % 3 == 0: + print("Fizz") + elif numbers % 5 == 0: + print("Buzz") + else: + print(numbers) + + +##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!") +num_letters = int(input("How many letters would you like in your password?\n")) +num_symbols = int(input("How many symbols would you like?\n")) +num_numbers = int(input("How many numbers would you like\n")) +#Level 1 +password = "" +for char in range(1, num_letters + 1): + rand_letter = random.choice(letters) + password += rand_letter +for char in range(1, num_symbols + 1): + rand_symbol = random.choice(symbols) + password += rand_symbol +for char in range(1, num_numbers + 1): + rand_number = random.choice(numbers) + password += rand_number +print(password) +#Or +#Level 2 +password_list = [] +for char in range(1, num_letters +1): + rand_letter = random.choice(letters) + password_list.append(rand_letter) +for char in range(1, num_symbols + 1): + rand_symbol = random.choice(symbols) + password_list.append(rand_symbol) +for char in range(1, num_numbers + 1): + rand_number = random.choice(numbers) + password_list.append(rand_number) +random.shuffle(password_list) +password = "" +for char in password_list: + password += char +print(f"Your password is {password}") \ No newline at end of file diff --git a/#Randomization b/#Randomization new file mode 100644 index 0000000..a494cc0 --- /dev/null +++ b/#Randomization @@ -0,0 +1,87 @@ +##Randomization +import random +import esters_code + +print(esters_code.tom) + +random_number = random.randint(1,100) +print(random_number) + +random_float = random.random() * 10 +print(random_float) + +love_score = random.randint(1, 100) +print(f"Your love score is {love_score}") + +#Mini project +#Create random sides of a coin: Heads or Tails +test_seed = int(input("Create a seed number: ")) +random.seed(test_seed) +#generate random integers btw 0 and 1 +random_side =random.randint(0,1) +if random_side == 1: + print("Heads") +else: + print("Tails") + + ##Offset and Appending Items to List + +states_of_america = ["Delaware", "Pennsylvania", "New Jersey", "Georgia", "Connecticut", "Massachusetts", "Maryland", "South Carolina", "New Hampshire", "Virginia", "New York", "North Carolina", "Rhode Island", "Vermont", "Kentucky", "Tennessee", "Ohio", "Louisiana", "Indiana", "Mississippi", "Illinois", "Alabama", "Maine", "Missouri", "Arkansas", "Michigan", "Florida", "Texas", "Iowa", "Wisconsin", "California", "Minnesota", "Oregon", "Kansas", "West Virginia", "Nevada", "Nebraska", "Colorado", "North Dakota", "South Dakota", "Montana", "Washington", "Idaho", "Wyoming", "Utah", "Oklahoma", "New Mexico", "Arizona", "Alaska",] +states_of_america.append("Esters Island") +states_of_america[0] +print(states_of_america[0]) +states_of_america[-2] = "Monkey Land" +states_of_america.extend(["Cupy Date", "Detty December", "Monkey Land"]) +states_of_america.insert(12, "Iceland") +states_of_america.remove("Iceland") +states_of_america.pop() +states_of_america.reverse() +states_of_america.sort() +print(states_of_america) + +my_country = states_of_america.copy() +print(my_country) + +###Mini Project 2 +##Who is paying the bill? +#Get to randomly select a person to pay the bills from a list of names + +import random + +name_csv = input("Give me everybody's names,separated by a comma.") +names = name_csv.split(", ") +num_names = len(names) +random_num = random.randint(0, num_names - 1) +name_chosen = names[random_num] +print(f"{name_chosen} is going to pay for the meal, today.") + +#Or use the random.choice() function +name_csv = input("Give me everybody's names,separated by a comma.") +names = name_csv.split(", ") +name_choice = random.choice(names) +print(f"{name_choice} is going to pay for the meal, today.") + +#Nested lists +box = [] +fruits = ["apple", "banana", "cherry", "strawberry", "mango", "grape", "orange", "melon", "kiwi", "pineapple"] +vegetables = ["carrot", "cabbage", "lettuce", "spinach", "cucumber", "tomato", "onion", "potato", "pea", "broccoli"] +box = [fruits, vegetables] +print(box) + +#Mini Test +#Position of treasure using two-digit numbers + +row1 = ["🟦", "🟦", "🟦"] +row2 = ["🟦", "🟦", "🟦"] +row3 = ["🟦", "🟦", "🟦"] +map = [row1, row2, row3] +print(f"{row1}\n{row2}\n{row3}") + +position = input("Where do you want to put your treasure?") +row = int(position[0]) +column = int(position[1]) +selected_row = map[row - 1] +selected_row[column - 1] = "X" +#Or +map[row - 1][column - 1] = "X" +print(f"{row1}\n{row2}\n{row3}") \ No newline at end of file diff --git a/#Rock, Paper, Scissors Game:.py b/#Rock, Paper, Scissors Game:.py new file mode 100644 index 0000000..8f0b10d --- /dev/null +++ b/#Rock, Paper, Scissors Game:.py @@ -0,0 +1,68 @@ +##Rock, Paper, Scissors Game: + +rock = ''' + _______ + ---' ____) + (_____) + (_____) + VK (____) + ---.__(___) + ''' +paper = ''' + _______ + ---' ____)____ + ______) + _______) + VK _______) + ---.__________) + ''' +scissors = ''' + _______ + ---' ____)____ + ______) + __________) + VK (____) + ---.__(___) + ''' +import random +fig = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n")) +if fig == 0: + print(rock) +elif fig == 1: + print(paper) +else: + print(scissors) +#Computer's choice +print("Computer's choice:") +computer_choice = random.randint(0,2) +if computer_choice ==0: + print(rock) +elif computer_choice == 1: + print(paper) +else: + print(scissors) + #Game logic +if fig == computer_choice: + print("It's tie, give it another try") + fig = int(input("Pick another number:")) + if fig == 0: + print(rock) + elif fig == 1: + print(paper) + else: + print(scissors) + #Player wins +elif fig == 0 and computer_choice == 2: + print("You win! Do you want to play again?") +elif fig == 1 and computer_choice == 2: + print("You win! Do you want to play again?") +elif fig == 2 and computer_choice == 1: + print("You win! Do you want to play again?") + #Computer wins +if computer_choice == 0 and fig == 2: + print("You lose!, do you want to play again?") +elif computer_choice == 1 and fig == 0: + print("You lose!, do you want to play again?") +elif computer_choice == 2 and fig == 1: + print("You lose!, do you want to play again?") + \ No newline at end of file diff --git a/#Treasure Island.py b/#Treasure Island.py new file mode 100644 index 0000000..c299814 --- /dev/null +++ b/#Treasure Island.py @@ -0,0 +1,48 @@ +#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_.--""___/______/______/______/____ +/______/______/______/______/______/______/______/______/______/______/[TomekK] +******************************************************************************* +''') + +print("Welcome to Treasure Island.") +print("Your mission is to find the treasure.") +choice1 = input("You're at a cross road. Where do you want to go? Type 'left' or 'right'\n") +lower_choice1 = choice1.lower() +if lower_choice1 == "left": + print("You have come to a lake. There is an island in the middle of the lake.") + choice2 = input("Type 'wait' to wait for a boat. Type 'swim' to swim across.\n") + lower_choice2 = choice2.lower() + if lower_choice2 == "wait": + print("You arrive at the island unharmed. There is a house with 3 doors. One red, one yellow and one blue.") + choice3 = input("Which colour do you choose?\n") + colour = choice3.lower() + if colour == "red": + print("You just got burned by the flame from a dinosaur mouth. Game Over.") + elif colour == "yellow": + print("You found the treasue and won the game. Congratulations! You are now rich. Get ready for the next adventure.") + else: + print("You got eaten by a blue dragon. Game Over.") + else: + print("You got attacked by an angry sea beast. Game Over.") +else: + print("You fell into a hole and died. Game Over.") + \ No newline at end of file diff --git a/.idea/.gitignore b/.github/100 Days Python Coding/.idea/.gitignore similarity index 100% rename from .idea/.gitignore rename to .github/100 Days Python Coding/.idea/.gitignore diff --git a/.github/100 Days Python Coding/Day 1 python coding.py b/.github/100 Days Python Coding/Day 1 python coding.py new file mode 100644 index 0000000..4f74047 --- /dev/null +++ b/.github/100 Days Python Coding/Day 1 python coding.py @@ -0,0 +1,34 @@ +print("Day 1 - Python Print Function") +print("The function is declared like this:") +print("print('what to print')") + + +## String Manipulation +print("Hello World!\nHello World!") + #Concatenation +print("Hello" + " " + "Tomiwa") +#Input Function +input("WHat is your name?") +print("Hello" + input("What is your name?")) +#Exercise +print(len(input("What is your name?"))) + +#Variables +name = input("What is your name?") +length = len(name) +print(length) +#exercise +a = input("a:") +b = input("b:") +c = a +a = b +print("a =" + a) +print("b =" + c) + +# Project- Band_name_generator +print("Welcome to the Band Name Generator.") +City = input("WHat is the name of the city you grew in?\n") +Pet = input("What is the name of your pet?\n") +Band_name = City + " " + Pet +print("Your band name could be " + Band_name) + diff --git a/.github/100 Days Python Coding/Day 2 python coding.py b/.github/100 Days Python Coding/Day 2 python coding.py new file mode 100644 index 0000000..d468322 --- /dev/null +++ b/.github/100 Days Python Coding/Day 2 python coding.py @@ -0,0 +1,35 @@ +# Data types and casting +Two_digit_number = input("Type a two digit number: ") +# print(type(Two_digit_number)) +first_digit = int(Two_digit_number[0]) +second_digit = int(Two_digit_number[1]) +Output = first_digit + second_digit +print(Output) + +# Mathematical Operations +# BMI +height = input("Enter your height in m: ") +weight = input("Enter your weight in kg: ") +BMI = int(weight)/float(height)**2 +print(int(BMI)) + +# Number manipulation & F strings +age = int(input("What is your current age?")) +age_left_yrs = 90 - age +age_left_days = age_left_yrs * 365 +age_left_wks = age_left_yrs * 52 +age_left_mnths = age_left_yrs *12 +message = f"You have {age_left_days} days, {age_left_wks} weeks, and {age_left_mnths} months left." +print(message) + +# Project 2: Tip Calculator +print("Welcome to the tip calculator.") +bill = float(input("What was the total bill? $")) +tip = int(input("What percentage tip would you like to give? 10, 12, or 15? ")) +percentage_tip = tip / 100 +total_bill = bill * (1 + percentage_tip) +No_of_people = int(input("How many people to split the bill? ")) +each_person_bill = total_bill / No_of_people +rounded_bill = round(each_perso) +output = f"Each person should pay: ${each_person_bill}" +print(output) \ No newline at end of file diff --git a/.github/100 Days Python Coding/Day 3 python coding.py b/.github/100 Days Python Coding/Day 3 python coding.py new file mode 100644 index 0000000..c8cba3a --- /dev/null +++ b/.github/100 Days Python Coding/Day 3 python coding.py @@ -0,0 +1,175 @@ +#Control overflow; if else and conditional statements +number = int(input("Which number do you want to check? ")) +if number %2 == 0: + print("This is an even number.") +else: + print("This is an odd number.") + +#Nested if and elif statements +# Ticket issuance +height = int(input("What is your height in cm? ")) +if height >= 120: + print("You can ride the rollercoaster!") + age = int(input("What is your age? ")) + if age <= 12: + print("Please pay $5.") + elif age <= 18: + print("Please pay $7.") + else: + print("Please pay $12.") +else: + print("Sorry, you have to grow taller before you can ride.") + +# BMI Calculator Advanced +height = float(input("Enter your height in m: ")) +weight = float(input("Enter your weight in kg: ")) +bmi = round(weight / height ** 2, 1) +if bmi < 18.5: + print(f"Your BMI is {bmi}, you are underweight.") +elif bmi <= 25: + print(f"Your BMI is {bmi}, you have a normal weight.") +elif bmi <= 30: + print(f"Your BMI is {bmi}, you are slightly overweight.") +elif bmi <= 35: + print(f"Your BMI is {bmi}, you are obese.") +else: + print(f"Your BMI is {bmi}, you are clinically obese.") + +# Exercise: Leap Year +year = int(input("Which year do you want to check? ")) +if year % 4 == 0: + if year % 100 == 0: + if year % 400 == 0: + print(f"The year {year} is a leap year.") + else: + print(f"The year {year} is not a leap year.") + else: + print(f"The year {year} is a leap year.") +else: + print(f"The year {year} is not a leap year.") + +# Multiple if statements in succession +height = int(input("What is your height in cm? ")) +bill = 0 +if height >= 120: + print("You can ride the rollercoaster!") + age = int(input("What is your age? ")) + if age <= 12: + bill = 5 + print("child ticket is $5.") + elif age <= 18: + bill = 7 + print("Youth ticket is $7.") + elif age >= 45 and age <= 55: + print("We have got a special offer for you. Your ticket is free.") + else: + bill = 12 + print("Adult ticket is $12.") + photo_shoot = input("Do you want a photo taken? Y or N. ") + if photo_shoot == "Y": + bill += 3 + print(f"Your final bill is ${bill}.") +else: + print("Sorry, you have to grow taller before you can ride.") + +# Exercise: Pizza Order +print("Welcome to Sumptuous Pizza Deliveries!") +size = input("What pizza size would you like to get? S, M, or L. ") +pepperoni = input("Do you want pepperoni? Y or N. ") +bill = 0 +if size == "S": + bill += 15 + print("Small pizza is $15.") +elif size == "M": + bill += 20 + print("Medium pizza is $20.") +else: + bill += 25 + print("Large pizza is $25.") +if pepperoni == "Y": + if size == "S": + bill += 2 + else: + bill += 3 +extra_cheese = input("Do you want extra cheese? Y or N. ") +if extra_cheese == "Y": + bill += 1 +print(f"Your final bill is: ${bill}.") + +# Exercise: Love Calculator +print("Welcome to the Love Calculator!") +print("Input your first and last names only to get your love score.") +name1 = input("What is your name? \n") +name2 = input("What is their name? \n") +combined_names = name1 + name2 +lower_case_names = combined_names.lower() +t = lower_case_names.count("t") +r = lower_case_names.count("r") +u = lower_case_names.count("u") +e = lower_case_names.count("e") +l = lower_case_names.count("l") +o = lower_case_names.count("o") +v = lower_case_names.count("v") +e = lower_case_names.count("e") +true = t + r + u + e +love = l + o + v + e +true_love = str(true) + str(love) +true_love_int = int(true_love) +print("Your love score is calculating...") +if true_love_int < 10 or true_love_int > 90: + print(f"Your score is {true_love_int}, you go together like coke and mentos.") +elif true_love_int >=40 and true_love_int <= 50: + print(f"Your score is {true_love_int}, you are alright together.") +else: + print(f"Your score is {true_love_int}, we hope you get along together.") + +# 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_.--""___/______/______/______/____ +/______/______/______/______/______/______/______/______/______/______/[TomekK] +******************************************************************************* +''') + +print("Welcome to Treasure Island.") +print("Your mission is to find the lost treasure that is hidden at the end of a desserted island") +print("You just landed on the island by an helicopter and you are at the crossroad now. Where do you want to go?") +first_choice = input('Type "left" or "right" to choose your path.\n') +first_choice_lower = first_choice.lower() +first_move = first_choice_lower.strip() +if first_move == "left": + print("You have chosen the left path. You have successfully crossed the dark forest and now, you are at the lake side. What do you want to do?") + second_choice = input('Type "wait" to wait for a boat or type "swim" to swim across the lake. The choice is yours, make your decision quickly.\n') + second_choice_lower = second_choice.lower() + second_move = second_choice_lower.strip() + if second_move == "wait": + print("You have chosen the right choice. You have successfully boarded a boat and now, you have reached the island. You are now in front of the castle where the treasure is hidden. Wanna get the treasure?") + third_choice = input('You wanna proceed further? Type "Blue", "Red" or "Yellow" to choose the door you want to open. Be very careful, the wrong choice will cost you your dear life.\n') + third_choice_lower = third_choice.lower() + third_move = third_choice_lower.strip() + if third_move == "yellow": + print("Congratulations! You have found the treasure hidden for decades. Now, you can return home as a hero and conqueror. Your people will be proud of you. You have won the game.") + elif third_move == "red": + print("You just opened a door full of packs of hungry wolves, how would you survive? You have been eaten alive by the wolves. Game Over.") + else: + print("You just opened a door full of fire. You have been smoked to ashes by the fire. Game Over.") + else: + print("What a bad decision you just made! You have been eaten by a crocodile. Game Over.") +else: + print("You have chosen the right path. Unfortunately, you have been biten by a poisonous snake and died. Game Over.") \ No newline at end of file diff --git a/.github/100 Days Python Coding/Day 4 python coding.py b/.github/100 Days Python Coding/Day 4 python coding.py new file mode 100644 index 0000000..cee51e9 --- /dev/null +++ b/.github/100 Days Python Coding/Day 4 python coding.py @@ -0,0 +1,114 @@ +# Random Module +import random +random_integer = random.randint(1, 20) +print(random_integer) +# Random_float +random_float = random.random() +print(random_float) + +# Exercise +test_seed = int(input("Create a seed number: ")) +random.seed(test_seed) +coin_side = random.randint(0, 1) +if coin_side == 0: + print("Heads") +else: + print("Tails") + +# Lists +states_of_america = ["Delaware", "Pennsylvania", "New Jersey", "Georgia", "Connecticut", "Massachusetts", "Maryland", "South Carolina", "New Hampshire", "Virginia", "New York", "North Carolina", "Rhode Island", "Vermont", "Kentucky", "Tennessee", "Ohio", "Louisiana", "Indiana", "Mississippi", "Illinois", "Alabama", "Maine", "Missouri", "Arkansas", "Michigan", "Florida", "Texas", "Iowa", "Wisconsin", "California", "Minnesota", "Oregon", "Kansas", "West Virginia", "Nevada", "Nebraska", "Colorado", "North Dakota", "South Dakota", "Montana", "Washington", "Idaho", "Wyoming", "Utah", "Oklahoma", "New Mexico", "Arizona", "Alaska", "Hawaii"] +print(states_of_america[0]) +print(states_of_america[-1]) +states_of_america.insert(0, "Puerto Rico") +states_of_america.insert(len(states_of_america), "News State") +print(states_of_america) + +# Exercise: Who is paying the bill? +test_seed = int(input("Create a seed number: ")) +random.seed(test_seed) +names_string = input("Give me everybody's names including yours separated by a comma. ") +names = names_string.split(", ") +name_length = len(names) +random_choice = random.randint(0, name_length - 1) +chosen_name = names[random_choice] +print(f"{chosen_name} is going to buy the meal today!") + +# Nested Lists +fruits = ["Strawberries", "Nectarines", "Apples", "Grapes", "Peaches", "Cherries", "Pears"] +vegetables = ["Spinach", "Kale", "Tomatoes", "Celery", "Potatoes"] +dirty_dozen = [fruits, vegetables] +print(dirty_dozen) + +# Exercise: 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[0]) +vertical = int(position[1]) +selected_row = map[vertical - 1] +selected_row[horizontal - 1] = "X" +print(f"{row1}\n{row2}\n{row3}") + +# Project: Rock Paper Scissors +rock = ''' + _______ + ---' ____) + (_____) + (_____) + VK (____) + ---.__(___) + ''' +paper = ''' + _______ + ---' ____)____ + ______) + _______) + VK _______) + ---.__________) + ''' +scissors = ''' + _______ + ---' ____)____ + ______) + __________) + VK (____) + ---.__(___) + ''' +import random +fig = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors. ")) +if fig == 0: + print(rock) +elif fig == 1: + print(paper) +else: + print(scissors) +computer_choice = random.randint(0, 2) +if computer_choice == 0: + print(f"Computer chose:\n{rock}") +elif computer_choice == 1: + print(f"Computer chose:\n{paper}") +else: + print(f"Computer chose:\n{scissors}") +if fig == 0 and computer_choice == 0: + print("It's a draw") +elif fig == 0 and computer_choice == 1: + print("You lose") +elif fig == 0 and computer_choice == 2: + print("You win") +elif fig == 1 and computer_choice == 0: + print("You win") +elif fig == 1 and computer_choice == 1: + print("It's a draw") +elif fig == 1 and computer_choice == 2: + print("You lose") +elif fig == 2 and computer_choice == 0: + print("You lose") +elif fig == 2 and computer_choice == 1: + print("You win") +elif fig == 2 and computer_choice == 2: + print("It's a draw") +else: + print("You typed an invalid number, try again") \ No newline at end of file diff --git a/.github/100 Days Python Coding/Day 5 python coding.py b/.github/100 Days Python Coding/Day 5 python coding.py new file mode 100644 index 0000000..e889567 --- /dev/null +++ b/.github/100 Days Python Coding/Day 5 python coding.py @@ -0,0 +1,91 @@ +# # For Loop +fruits = ["apples", "pears", "oranges", "bananas"] +for fruit in fruits: + print(fruit) + print(fruit + "pie") +# Exercise 1: Average Height +student_heights = input("Input a list of student heights ").replace(',', ' ').split() +for n in range(0, len(student_heights)): + student_heights[n] = int(student_heights[n]) +total_height = 0 +for height in student_heights: + total_height += height +num_of_students = 0 +for student in student_heights: + num_of_students += 1 +average_height = round(total_height / num_of_students) +print(f"The average height is {average_height}") + +# Exercise 2: The Highest Score +student_scores = input("Input a list of student scores ").replace(', ', ' ').split() +for n in range(0, len(student_scores)): + student_scores[n] = int(student_scores[n]) +highest_score = 0 +for score in student_scores: + if score > highest_score: + highest_score = score + else: + highest_score = highest_score +print(f"The highest score in the class is: {highest_score}") + +# Exercise 3: Adding Even Numbers +total = 0 +for num in range(2, 101, 2): + total += num +print(total) +# or +total1 = 0 +for num in range(1, 101): + if num % 2 == 0: + total1 += num +print(total1) + +# Exercise 4: FizzBuzz Game +for num in range(1, 101): + if num % 3 == 0 and num % 5 == 0: + print("FizzBuzz") + elif num % 3 == 0: + print("Fizz") + elif num % 5 == 0: + print("Buzz") + else: + print(num) + +# Project: PyPassword Generator +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!") +no_letters = int(input("How many letters would you like in your password?\n")) +no_symbols = int(input("How many symbols would you like?\n")) +no_numbers = int(input("How many numbers would you like?\n")) +password = "" +for char in range(1, no_letters + 1): + password += random.choice(letters) +for char in range(1, no_symbols + 1): + password += random.choice(symbols) +for char in range(1, no_numbers + 1): + password += random.choice(numbers) +#Randomize password +randomized_password = "" +for num in range(1, len(password) + 1): + randomized_password += random.choice(password) +print(f"Your password is: {randomized_password}") +#or +password_list = [] +for char in range(1, no_letters + 1): + password_list.append(random.choice(letters)) +for char in range(1, no_symbols + 1): + password_list.append(random.choice(symbols)) +for char in range(1, no_numbers + 1): + password_list.append(random.choice(numbers)) +random.shuffle(password_list) +# Randomized password +password = "" +for char in password_list: + password += char +print(f"Your password is: {password}") \ No newline at end of file diff --git a/.github/100 Days Python Coding/Day 6 python coding.py b/.github/100 Days Python Coding/Day 6 python coding.py new file mode 100644 index 0000000..f9c75eb --- /dev/null +++ b/.github/100 Days Python Coding/Day 6 python coding.py @@ -0,0 +1,95 @@ +# Defining & calling function +def my_function(): + print("Hello, welcome to my world") + print("See you soon") +my_function() +# Exercise 1: Reeborg's World +def turn_right(): + turn_left() + turn_left() + turn_left() +#draw square +move() +turn_right() +move() +turn_right() +move() +turn_right() +move() +#Exercise 2 +def turn_right: + turn_left() + turn_left() + turn_left() +def jump(): + turn_left() + move() + turn_right() + move() + turn_right() + move() +def jump_hurdle(): + move() + jump() + turn_left() +#Hurdle race +for step in range(6): + jump_hurdle() + +#While loop +def turn_right: + turn_left() + turn_left() + turn_left() +def jump(): + turn_left() + move() + turn_right() + move() + turn_right() + move() + turn_left() +while not at_goal(): + if wall_in_front(): + jump() + else: + move() + +#exercise: jumping over hurdles with variable heights +def turn_right: + turn_left() + turn_left() + turn_left() +def jump(): + turn_left() + while wall_on_right(): + move() + turn_right() + move() + turn_right() + while front_is_clear(): + move() + turn_left() + +while not at_goal(): + if wall_in_front(): + jump() + else: + move + +#exercise: project +def turn_right: + turn_left() + turn_left() + turn_left() + +while not at_goal(): + if right_is_clear(): + turn_right() + move() + elif front_is_clear(): + move + else: + turn_left() + + #All code was run on Reeborg's World website \ No newline at end of file diff --git a/.github/100 Days Python Coding/Day 7 python coding.py b/.github/100 Days Python Coding/Day 7 python coding.py new file mode 100644 index 0000000..8c5dd5d --- /dev/null +++ b/.github/100 Days Python Coding/Day 7 python coding.py @@ -0,0 +1,63 @@ +# Project: Hangman +import random +from hangman_art import stages, logo +from hangman_word import word_list +# from replit import clear + +# Logo +print(logo) + +# Randomly choose a word from the list +random_word = random.choice(word_list) +# print(random_word) + +# Number of lives available +lives = 6 +end_of_game = False + +# Create a list to display guessed letters if correct +display = [] +for letter in random_word: + display += "_" +print(display) +while not end_of_game: + +# Ask user to guess a letter from the word + guess = input("Guess a letter from the secret word: ").lower().strip() + + # User guessed a letter that is already guessed + if guess in display: + print(f"You've already guessed {guess}") + +# Check if the guessed letter is in the word + for position in range(len(random_word)): + letter = random_word[position] + if letter == guess: + display[position] = letter + if "_" not in display: + end_of_game = True + print("You win!") + print(display) + # clear() + + # Guess a wrong letter + if guess not in random_word: + print(f"You guessed {guess}, that's not in the word. You lose a life.") + lives -= 1 + if lives == 6: + print(stages[6]) + elif lives == 5: + print(stages[5]) + elif lives == 4: + print(stages[4]) + elif lives == 3: + print(stages[3]) + elif lives == 2: + print(stages[2]) + elif lives == 1: + print(stages[1]) + elif lives == 0: + print(stages[0]) + if lives == 0: + end_of_game = True + print("You lose!") \ No newline at end of file diff --git a/.github/100 Days Python Coding/hangman_art.py b/.github/100 Days Python Coding/hangman_art.py new file mode 100644 index 0000000..8d2e3f4 --- /dev/null +++ b/.github/100 Days Python Coding/hangman_art.py @@ -0,0 +1,66 @@ +logo = ''' +| | +| |__ __ _ _ __ __ _ _ __ ___ __ _ _ __ +| '_ \ / _` | '_ \ / _` | '_ ` _ \ / _` | '_ \ +| | | | (_| | | | | (_| | | | | | | (_| | | | | +|_| |_|\__,_|_| |_|\__, |_| |_| |_|\__,_|_| |_| + __/ | + |___/ + ''' + +stages = [''' + +---+ + | | + O | + /|\ | + / \ | + | +========= +''', ''' + +---+ + | | + O | + /|\ | + / | + | +========= +''', ''' + +---+ + | | + O | + /|\ | + | + | +========= +''', ''' + +---+ + | | + O | + /| | + | + | +=========''', ''' + +---+ + | | + O | + | | + | + | +========= +''', ''' + +---+ + | | + O | + | + | + | +========= +''', ''' + +---+ + | | + | + | + | + | +========= +'''] \ No newline at end of file diff --git a/.github/100 Days Python Coding/hangman_word.py b/.github/100 Days Python Coding/hangman_word.py new file mode 100644 index 0000000..b5d7f92 --- /dev/null +++ b/.github/100 Days Python Coding/hangman_word.py @@ -0,0 +1,210 @@ +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', + 'mystify', + 'myth', + 'napkin', + 'nappy', + 'nervous', + 'nightclub', + 'nowadays', + 'nuisance', + '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', + 'squawk', + 'staff', + 'strength', + 'strengths', + 'stretch', + 'stronghold', + 'subway', + 'swivel', + 'syndrome', + 'twelfth', + 'thriftless', + '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', + 'yachtsman', + 'yippee', + 'yoked', + 'youthful', + 'yummy', + 'zap', + 'zephyr', + 'zigzag', + 'zigzagging', + 'zilch', + 'zippy', + 'zombie', + 'zoom', + 'zooming', + 'zigzag', + 'zigzagging', + 'zipper', + 'zippering', + 'zippered', + 'zippering', +] \ No newline at end of file