Day 1

print("Hello World\nHello World\nHello World")
print("-------------------------")
print(" ### Name your Band ### ")
city = input("Name of city you were born in: ")
pet = input("Name of first pet: ")
print("Your band name is:",city + " " + pet)
print("-------------------------")
print("Hello " + input("What is your name") + "!")
-------------------------
### Name your Band ###
Name of city you were born in: San Francisco
Name of first pet: Dog
Your band name is: San Francisco Dog
-------------------------
What is your nameBob
Hello Bob!

Day 2

print("hello"[4]) # o
print("hello"[-1]) # o
print("123" + "456") #concat
print(123 + 456)
print(123_456_789)
print(type("12345"))
print(type(12345))
print(type(123.45))
print(type(True))

bmi = 84 / 1.65**2
print(bmi)
print(int(bmi*100)/100)
print(round(bmi,2))

score = 100
height = 1.8
is_winning = True

print(f" Your score is {score}, your height is {height}, Winning? {is_winning} ")

# declare variable type before input
print("Your Bill Calculator")
bill= float(input("How much is your bill?"))
tip= float(input("how much is your percent tip?"))
people = int(input("how many people are splitting the bill"))
billWithTip : float = bill*(1+(tip/100))
should_pay = round( billWithTip / people,2 )
#print formatted
formatted_number = f"${should_pay:.2f}"
print (f"Each person's bill is: {formatted_number}")
o
o
123456
579
123456789
<class 'str'>
<class 'int'>
<class 'float'>
<class 'bool'>
30.85399449035813
30.85
30.85
Your score is 100, your height is 1.8, Winning? True
Your Bill Calculator
How much is your bill?150
how much is your percent tip?12
how many people are splitting the bill5
Each person's bill is: $33.60

Day 3

# This shows the if condition is true and else condition is false
test = bool(3 > 4)
if test:
print ("True condition")
print(f"3 > 4 is {test}")
else:
print("False condition")
print(f"3 > 4 is {test}")

print("--------------------")

test = bool(4 > 3)
if test:
print ("True condition")
print(f"4 > 3 is {test}")
else:
print("False condition")
print(f"4 > 3 is {test}")

print("--------------------")

marks = 89
if marks >= 90:
grade = 'A'
elif marks >= 80:
grade = 'B'
elif marks >= 70:
grade = 'C'
elif marks >= 60:
grade = 'D'
else:
grade = 'F'

print(f"{marks} Your grade is:", grade)

print("--------------------")

# Odd or Even
number = 80
ans= bool(number % 2)
# if ans is FALSE, number is even
# if ans is TRUE, number is odd
if ans:
print(f"{number} is odd")
else:
print(f"{number} is even")

print("--------------------")

number = 81
ans= bool(number % 2)
# if ans is FALSE, number is even
# if ans is TRUE, number is odd
if ans:
print(f"{number} is odd")
else:
print(f"{number} is even")
False condition
3 > 4 is False
--------------------
True condition
4 > 3 is True
--------------------
89 Your grade is: B
--------------------
80 is even
--------------------
81 is odd

Day 5

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']
length_letter = len(letters)
ascii_Value = [None] * length_letter

# This forms a list for the ascii ord values for letters.
location = 0
for letter in letters:
ascii_Value[location] = ord(letter)
location += 1

print(letters)
print(ascii_Value)

print("-------------------")

print(" Encode and Decode phrases")
print(" no special characters other than spaces")
print("Shift of 0 and 26 are basically the same phrase")
print("-------------------")
Phrase = input("What is your phrase to encode: ")
shift = int(input("What is your shift 0 to 26: "))
Encoded_word = [None] * len(Phrase)

location = 0
for phrase in Phrase:
ord_value = ord(phrase)
new_value = ord_value + shift

# Shift Blank Spaces
if ord_value == 32:
print(chr(new_value))
Encoded_word[location] = chr(new_value)
location += 1

# Shift Capital Letters
if ord_value >= 65 and ord_value <= 90:
if new_value > 90:
new_ord_value = new_value - 90 + 65 - 1
Encoded_word[location] = chr(new_ord_value)
location += 1
else:
Encoded_word[location] = chr(new_value)
location += 1

# Shift Lower Case Letter
if ord_value >= 97 and ord_value <= 122:
if new_value > 122:
new_ord_value = new_value - 122 + 97 - 1
Encoded_word[location] = chr(new_ord_value)
location += 1
else:
Encoded_word[location] = chr(new_value)
location += 1

print(f"{Phrase} will become: ", end='' )
for word in Encoded_word:
print(word, end='')

print ("\n----------------------")
print("Transmitting code to HQ")
print ("Transfer Completed")
print ("----------------------")

# Decoding the message

print("Decoding stand by")

Decoded_word = [None] * len(Encoded_word)

#Find the key value for shift of the blank character

print("--------------")
print("Find decoding key")
print("--------------")

for word in Encoded_word:
ord_value = ord(word)

if ord_value < 65:
shift = ord_value - 32

print("--------------")
print("Start Decoding")
print("--------------")
location = 0
for word in Encoded_word:
new_value = ord(word) - shift
ord_value = ord(word)

# Blank
if ord_value == 32 + shift:
Decoded_word[location] = chr(32)
location += 1

#Shift Capital letters back to decode
if ord_value >= 65 and ord_value <= 90:
if new_value < 65:
new_ord_value = 90 - ( 65 - new_value - 1 )
Decoded_word[location] = chr(new_ord_value)
location += 1
else:
Decoded_word[location] = chr(new_value)
location += 1

# Shift Lower Case Letter
if ord_value >= 97 and ord_value <= 122:
if new_value < 97:
new_ord_value = 122 - ( 97 - new_value - 1)
Decoded_word[location] = chr(new_ord_value)
location += 1
else:
Decoded_word[location] = chr(new_value)
location += 1

print("--------------")
print("Decoded message standby")
print("--------------")
print("Message reads: ", end='')

for word in Decoded_word:
print(word, end='')


['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']
[97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90]
-------------------
Encode and Decode phrases
no special characters other than spaces
Shift of 0 and 26 are basically the same phrase
-------------------
What is your phrase to encode: The Hunt for Red October
What is your shift 0 to 26: 9
)
)
)
)
The Hunt for Red October will become: Cqn)Qdwc)oxa)Anm)Xlcxkna
----------------------
Transmitting code to HQ
Transfer Completed
----------------------
Decoding stand by
--------------
Find decoding key
--------------
--------------
Start Decoding
--------------
--------------
Decoded message standby
--------------
Message reads: The Hunt for Red October
Process finished with exit code 0

Day 8: Functions

def life_in_weeks(name, age):
time_left = (90 - age) * 52
print(f"{name} for the age of {age}, you have {time_left} weeks left")

def life_in_weeks_list(list_Name_Age):
for x in range(0, 5, 2):
name = list_Name_Age[x]
age = list_Name_Age[x+1]
time_left = (90 - age) * 52
print(f"{name} for the age of {age}, you have {time_left} weeks left")


life_in_weeks("Bob",20)
life_in_weeks("Carol",30)
life_in_weeks("Jeff",40)

print ("------------------------")
print ("keyword arguments")
print ("------------------------")
life_in_weeks(name="Bob",age=20)
life_in_weeks(age=20, name="Bob")

print ("------------------------")
print("From a list")
print ("------------------------")
Name_age = [ "Bob", 20, "Carol", 30, "Jeff", 40]
life_in_weeks_list(Name_age)
Bob for the age of 20, you have 3640 weeks left
Carol for the age of 30, you have 3120 weeks left
Jeff for the age of 40, you have 2600 weeks left
------------------------
keyword arguments
------------------------
Bob for the age of 20, you have 3640 weeks left
Bob for the age of 20, you have 3640 weeks left
------------------------
From a list
------------------------
Bob for the age of 20, you have 3640 weeks left
Carol for the age of 30, you have 3120 weeks left
Jeff for the age of 40, you have 2600 weeks left

Process finished with exit code 0

Day 9: Dictionaries

student_scores = {
'Harry': 88,
'Ron': 78,
'Hermione': 95,
'Draco': 75,
'Neville': 60
}

student_grades = {}

for student in student_scores:
grade = student_scores[student]
if grade >=91:
student_grades[student] = "Outstanding"
elif grade >= 81:
student_grades[student] = "Exceeds Expectations"
elif grade >= 71:
student_grades[student] = "Acceptable"
else:
student_grades[student] = "Fail"

print(f"{student} grade is {student_grades[student]}")


Harry grade is Exceeds Expectations
Ron grade is Acceptable
Hermione grade is Outstanding
Draco grade is Acceptable
Neville grade is Fail

Process finished with exit code 0

Day 10: Prime Numbers

from sympy import isprime
import math

# method 1 : using isprime function
def check_prime_sympy(n):
return isprime(n)

# method 2 longest method: check all numbers up to n-1
def is_prime_basic(n):
if n <= 1:
return False # Numbers less than or equal to 1 are not prime
for i in range(2, n):
if n % i == 0:
return False # Found a divisor, so it's not prime
return True # No divisors found, so it's prime

# method 3 check all numbers up square root of num
def is_prime_sqrt(n):
if n <= 1:
return False
# Iterate from 2 up to the integer part of the square root of n
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True

check_list = [2, 7, 75, 201]

for num_check in check_list:
print(f"{num_check} is prime {check_prime_sympy(num_check)}")
print(f"{num_check} is prime {is_prime_basic(num_check)}")
print(f"{num_check} is prime {is_prime_sqrt(num_check)}")
print("-------------------")


2 is prime True
2 is prime True
2 is prime True
-------------------
7 is prime True
7 is prime True
7 is prime True
-------------------
75 is prime False
75 is prime False
75 is prime False
-------------------
201 is prime False
201 is prime False
201 is prime False
-------------------

Process finished with exit code 0

Day 10: Number Guess

import random

number_guess = 0
number_chosen = random.randint(0,100)
difficulty = input("easy or hard")

while True:
your_choice = int( input("What is your number"))

if number_chosen == your_choice:
print("You won")
break
elif your_choice > number_chosen:
print("You are too high")
number_guess += 1
else:
print("Your number is too low")
number_guess += 1

if difficulty == "hard":
print(f"{number_guess} out of 5")
if number_guess == 5:
print("you lose")
break

if difficulty == "easy":
print(f"{number_guess} out of 10")
if number_guess == 10:
print("you lose")
break

easy or hardeasy
What is your number50
You are too high
1 out of 10
What is your number25
You are too high
2 out of 10
What is your number12
You are too high
3 out of 10
What is your number6
Your number is too low
4 out of 10
What is your number9
You are too high
5 out of 10
What is your number7
You won

Process finished with exit code 0