#Popcorn Hack
me = 'Akhil'
age = 354
print(f"I am {me} and I am {age} years old!!! ☢︎")
I am Akhil and I am 354 years old!!! ☢︎
#Popcorn Hack
secretNumber = 15
print(secretNumber)
food = "Pizza"
print(food)
names = ["Nandan", "Arnav", "Torin", "Remy"]
print(names)
IamCool = True
print(IamCool)
##Bonus Problem:
names_2 = {
"Nandan": "TeamMate1",
"Arnav": "TeamMate2",
"Torin": "TeamMate3",
"Remy": "TeamMate4",
}
print(type(secretNumber))
print(type(food))
print(type(names))
print(type(IamCool))
15
Pizza
['Nandan', 'Arnav', 'Torin', 'Remy']
True
<class 'int'>
<class 'str'>
<class 'list'>
<class 'bool'>
#Popcorn Hack
x = 15
y = 20
z = x
x = y
y = x - z
print(x, y, z)
20 5 15
#Popcorn Hack
string = 'Hippopotomonstrosesquippedaliophobia'
print(string[3])
p
# Homework
#Create class called person
class person:
def __init__(self, name, age):
self.name = name
self.age = age
#Get a list of people and print the info of each person
def print_people(list_of_people):
for person in list_of_people:
print(f"Name: {person}\nAge: {list_of_people[person]}")
#Get the oldest person
def print_oldest(list_of_people):
x = list(list_of_people.values())
x = x.index(max(x))
print(f"The oldest person is {list(list_of_people.keys())[x]}.")
#Create a dictionary of people
people = {}
#Add as many ppl as you want
keep_going = 'Y'
while keep_going == 'Y':
person = input('Enter person name: ')
people[person] = int(input('Input person age: '))
keep_going = input('Add another person [Y/N]? ').upper()
#print the order of dictionary based on both age and alphabetical order
def print_ordered(people):
names = list(people.keys())
ages = list(people.values())
names.sort()
ages.sort()
print(f'Ordered names list: {names}')
print(f'Ordered ages list: {ages}')
#Menu to choose what output you want
while True:
choice = input("Choose an option:\n1. Print info on everyone\n2. Find oldest person\n3. Order info on everyone into names and ages\n4. Exit\n")
if choice == '1':
print_people(people)
elif choice == '2':
print_oldest(people)
elif choice == '3':
print_ordered(people)
else:
break
Name: Akhil
Age: 15
Name: Advik
Age: 19
Name: Srijan
Age: 11
Name: Aashray
Age: 38
The oldest person is Aashray.
Ordered names list: ['Aashray', 'Advik', 'Akhil', 'Srijan']
Ordered ages list: [11, 15, 19, 38]