Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions #For Loop in Python.py
Original file line number Diff line number Diff line change
@@ -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}")
87 changes: 87 additions & 0 deletions #Randomization
Original file line number Diff line number Diff line change
@@ -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}")
68 changes: 68 additions & 0 deletions #Rock, Paper, Scissors Game:.py
Original file line number Diff line number Diff line change
@@ -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?")

48 changes: 48 additions & 0 deletions #Treasure Island.py
Original file line number Diff line number Diff line change
@@ -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.")

File renamed without changes.
34 changes: 34 additions & 0 deletions .github/100 Days Python Coding/Day 1 python coding.py
Original file line number Diff line number Diff line change
@@ -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)

35 changes: 35 additions & 0 deletions .github/100 Days Python Coding/Day 2 python coding.py
Original file line number Diff line number Diff line change
@@ -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)
Loading