x = 'I am Jared'
print(x)
y = 9
z = 8
print(y+z)
I am Jared
17
x = "Jared"
age = int(input("What is youre age?"))
if age > 10:
print("true")
else:
print("false")
true
i = input("Is this line straight or curvy? |")
if i == "straight":
print("Youre correct")
elif i == "curvy":
print("Come on, lets be real")
Come on, lets be real
suslist = ["I am Jared", 15, "Hello World", 12, "Ashwin is funny", 15]
print(suslist[5])
print(suslist[2])
print(suslist[0:2])
15
Hello World
['I am Jared', 15]
# Part 1: 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.
class Person:
def person(self, name, age):
self.name = name
self.age = age
def print_people(person):
for person in people:
print(person + " is " + str(people[person]) + " years old")
people = {
"Jared": "15",
"Bruce AKA Batman": "84",
"Ashwin": "109"
}
print_people(people)
Jared is 15 years old
Bruce AKA Batman is 84 years old
Ashwin is 109 years old
#Part 2: Create a function that takes in a dictionary of people and their ages and prints out
# the name of the oldest person.
def print_oldestperson(person):
oldest_person = max(people, key=lambda x: int(people[x]))
oldest_age = people[oldest_person]
print(oldest_person + " is " + oldest_age + " years old")
people = {
"Jared": "15",
"Bruce AKA Batman": "84",
"Ashwin": "109",
"Ashwin's Grandma": "218",
"Joker": "178"
}
print_oldestperson(people)
Ashwin's Grandma is 218 years old