Popcorn Hacks
age = int(input("How old you??"))
if age <= 16:
print ("You can Drive!!")
else:
print ("Cant drive yet")
SusList = [1, 2, 3, 4, 5]
print(SusList)
[1, 2, 3, 4, 5]
Home Work
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def print_people(people_list):
for person in people_list:
print(f"Name: {person.name}, Age: {person.age}")
def find_oldest_person(people_dict):
if not people_dict:
print("The dictionary is empty.")
return
oldest_person = max(people_dict, key=people_dict.get)
print(f"The oldest person is {oldest_person} with age {people_dict[oldest_person]}.")
person1 = Person("Ronnit", 16)
person2 = Person("Ashwin", 15)
person3 = Person("Jared", 56)
people_list = [person1, person2, person3]
people_dict = {
"Ronnit": 16,
"Vance": 15,
"Jared": 56
}
print("People in the list:")
print_people(people_list)
print("\nOldest person in the dictionary:")
find_oldest_person(people_dict)
People in the list:
Name: Ronnit, Age: 16
Name: Ashwin, Age: 15
Name: Jared, Age: 56
Oldest person in the dictionary:
The oldest person is Jared with age 56.