# Popcorn Hack 4
info = "asdfghjkl;'"
list = ["name", "height", "friend", True, 10.9, 20.1, [1,2,3,4]]
print("second element is")
print(list[2])
print("fourth element is")
print(list[4])
print("first element is")
print(list[1])
second element is
friend
fourth element is
10.9
first element is
height
{'name: ': 'Vance', 'age: ': 15}
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("Vance", 15)
person3 = Person("Greg", 56)
people_list = [person1, person2, person3]
people_dict = {
"Ronnit": 16,
"Vance": 15,
"Greg": 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: Vance, Age: 15
Name: Greg, Age: 56
Oldest person in the dictionary:
The oldest person is Greg with age 56.