#Popcorn Hack 1

name = "Ronit Thomas"
print(name)

toes = 10
print(toes)
Ronit Thomas
10
#Popcorn Hack 2

superhero = "Batman"
print(superhero)

number_of_villans=15
print(number_of_villans)

number_of_cars=4
print(number_of_cars<3)
Batman
15
False
# Popcorn Hack 3 

num1 = 30 
num2 = 45
num3 = 76

print(str(num1)+" "+str(num2)+" "+str(num3))
print("changing all numbers to the same number: ")

num1=num2
num2=num2
num3=num2

print(str(num1)+" "+str(num2)+" "+str(num3))
print("all numbers are now the same.")


30 45 76
changing all numbers to the same number: 
45 45 45
all numbers are now the same.
# Popcorn Hack 4 

information = "feSECRETgrogiegifshdfsfdhskb"

list=["Batman", "Superman", True, 12.4, 18.3, [1,2,3,4]]

print("The second element(third) is:")
print(list[2])

print("The fourth element(fifth) is:")
print(list[4])

The second elemen(third) is:
True
The fourth elemen(fifth) is:
18.3
# Popcorn Hack 5

dictionary = {
    "Name: ": "Ronit",
    "Age: ":16
}

print(dictionary)


import json
list = ["Batman", "Batman Mobile", "Batman Copter", "Batman Boat"]
json_obj = json.dumps(list)
print(json_obj)
{'Name: ': 'Ronit', 'Age: ': 16}
["Batman", "Batman Mobile", "Batman Copter", "Batman Boat"]

Data Abstraction Homework

Create a class called Person with the attributes name and age. Then create a function called print_people that takes in a list of people and prints out their names and ages.



def __init__(self, name, age):
    self.name = name
    self.age = age

def print_people(people):
    for person in people:
        print(person.name + " is " + str(person.age) + " years old") 

person1 = Person("Ronit", 16)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
num = int(input("Enter how many people you want to add: "))

for i in range(num):
    name = input("Enter name: ")
    age = int(input("Enter Age: "))
    dude=Person(name, age)
    people.append(dude)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
print_people(people)
Ronit is 16 years old
Vance is 15 years old
Lincoln is 15 years old
Jared is 16 years old

Create a function that takes in a dictionary of people and their ages and prints out the name of the oldest person.

def oldest(dudes):
    oldest_name = ""
    oldest_age = 0
    
    for name, age in dudes.items():
        if age > oldest_age:
            oldest_name = name
            oldest_age = age
            
    print("The oldest person is: " + oldest_name + " with the age of: " + str(oldest_age))

dudes = {
    "Ronit": 16,
    "Lincoln": 15,
    "Vance": 18,
    "Bronny": 43
}

oldest(dudes)
The oldest person is: Bronny with the age of: 43