Udemy Python day 1 to 10
Day 1
Day 2
Day 3
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") + "!")
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}")
# 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")
-------------------------
### 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!
C:\Users\Win10x64i7\AppData\Local\Microsoft\WindowsApps\python3.12.exe C:\Users\Win10x64i7\PycharmProjects\Day2\Day2.py
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
Process finished with exit code 0
C:\Users\Win10x64i7\AppData\Local\Microsoft\WindowsApps\python3.12.exe C:\Users\Win10x64i7\PycharmProjects\Day3\Day3.py
False condition
3 > 4 is False
--------------------
True condition
4 > 3 is True
--------------------
89 Your grade is: B
--------------------
80 is even
--------------------
81 is odd
Process finished with exit code 0