TDWolff / NART_Movie

MIT License
0 stars 0 forks source link

NART_Movie//2023/09/25/Team_Teach_IPYNB_2_ #8

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Data Abstraction | Movie Blogs

Team Teaching

https://tdwolff.github.io/NART_Movie/2023/09/25/Team_Teach_IPYNB2.html

IshanCornick commented 1 year ago

class Person: def init(self, name, age): self.name = name self.age = age

def print_people(people): for person in people.values(): print(f"Name: {person.name}, Age: {person.age}")

def find_old(people_dict): if not people_dict: print("The dictionary is empty.") return

oldest_person = max(people_dict, key=lambda x: people_dict[x])

print(f"The oldest person is {oldest_person} with age {people_dict[oldest_person]}")

people_list = { "kid1": Person("kid1", 1), "kid2": Person("kid2", 2), "kid3": Person("kid3", 3) }

print_people(people_list)

people_dict = {"kid1": 1, "kid2": 2, "kid3": 3} find_old(people_dict)

LincolnC2008 commented 1 year ago

Homework Part 1

class Person: def init(self, name, age): self.name = name self.age = age

def print_people(people): for person in people: print(f"Name: {person.name}, Age: {person.age}")

person1 = Person("Ronit", 15) person2 = Person("Lincoln", 15) person3 = Person("Ishan", 15)

people_list = [person1, person2, person3]

print_people(people_list)

Homework Part 2

def find_oldest_person(people): oldest_name = None max_age = -1

for name, age in people.items():
    if age > max_age:
        max_age = age
        oldest_name = name

if oldest_name is not None:
    print(f"The oldest person is {oldest_name} with an age of {max_age}.")
else:
    print("The provided dictionary is empty.")

family_dict = { "Mom": 47, "Dad": 44, "Lincoln": 15 }

find_oldest_person(family_dict)

IshanCornick commented 1 year ago

https://ishancornick.github.io/new_student//2023/10/04/python-homework_IPYNB_2_.html

JBaza12 commented 1 year ago

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)

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", "Joke": "178" } print_oldestperson(people)

http://127.0.0.1:4200/JaredsBlog//2023/10/04/DataAbstraction_IPYNB_2_.html

ninaadkiran commented 1 year ago

class Product: def init(self, name, price, quantity): self.name = name self.price = price self.quantity = quantity

def calculate_total(self):
    return self.price * self.quantity

def calculate_total_price(products): total_price = 0 for product in products: total_price += product.calculate_total() return total_price

product1 = Product("Laptop", 999.99, 3) product2 = Product("Mouse", 19.99, 5) product3 = Product("Keyboard", 49.99, 2)

product_list = [product1, product2, product3]

total_price = calculate_total_price(product_list)

print(f"Total price of all products: ${total_price:.2f}")

SrijDude3416 commented 1 year ago

https://srijdude3416.github.io/student//2023/10/02/Variables_IPYNB_2_.html

trevorhuang1 commented 1 year ago

https://trevorhuang1.github.io/csp_blog//2023/10/04/Data-Abstraction_IPYNB_2_.html

YeongsuKimm commented 1 year ago

class Person: def init(self, name, age): self.name = name; self.age = age;

person1 = Person("John", 13); person2 = Person("Doe", 16); person3 = Person("HON", 12);

lst = [person1, person2, person3]; def print_people(Personlst): for i in range(len(Personlst)): print(Personlst[i].name, end= ": "); print(Personlst[i].age);

print_people(lst);

dict = { "one": person1, "two": person2, "three": person3, } def print_oldest(pdict): oldest = list(pdict.keys())[0] oldest_age = pdict[oldest].age for name in pdict.keys(): if pdict[name].age > oldest_age: oldest = name oldest_age = pdict[name].age print(pdict[oldest].name)

print_oldest(dict)

import json

secretNumber = 15 print(secretNumber) #int print(type(secretNumber))

food = "Pizza" print(food) #string print(type(food))

names = ["Nandan", "Arnav", "Torin", "Remy"] print(names) # array or list print(type(names))

IamCool = True

print(IamCool) # boolean print(type(IamCool))

Bonus Problem:

names_2 = { "Nandan": "TeamMate1", "Arnav": "TeamMate2", "Torin": "TeamMate3", "Remy": "TeamMate4", }

print(names_2) #dictionary print(type(names_2))

variables = { "numbers": [1,2,3,4,5], "names": ["John", "Robert", "Bob", "Doe", "Bill"], "isDict": True, }

def print_largest(dict): max = dict["numbers"][0]; for i in range(1, len(dict["numbers"])): if max < dict["numbers"][i]: max = dict["numbers"][i]; print(f"Largest Number is {max}")

longestName = dict["names"][1];
max = len(dict["names"][0])
for i in range(1, len(dict["names"])):
    if max < len(dict["names"][i]):
        max = len(dict["names"][1]);
print(f"Longest Name is {longestName}");

if(dict["isDict"]):
    print("This is a dictionary");
else:
    print("This is not a dictionary");

print_largest(variables);

tanayshah1 commented 1 year ago

def annuity(rate, C, months, rate_check, month_check): if str(rate_check) == "percent": rate=rate/100

if str(month_check) == 'year': 
    months = months*12

PV = (C/rate)*(1-(1/(1+rate)**months))
annuity = PV + C
print("The annuity is: {:.2f}$".format(annuity))

def perpetuity(rate, C, rate_check): if str(rate_check) == "percent": rate = rate/100

    PV = C/rate
    print("The perpetuity of your deposit is: {:.2f}$".format(PV))

def futureValue(rate, PV, months, rate_check, month_check): if str(rate_check) == "percent": rate = rate/100

    if str(month_check) == "year": 
        months = months*12

    FV = float(PV)*(1+float(rate))**float(months)
    print("The future value of your deposit is: {:.2f}$".format(FV))
brandonso36 commented 1 year ago

questions = ["What period do I have AP CSP?", "What was this lesson on?", "What type of variable is used for numbers?"] answers = ["5", "Data Abstraction", "Integer"]

score = 0 question_index = 0

while question_index < len(questions): print("Question", question_index + 1, ":", questions[question_index]) user_answer = input("Enter your answer: ")

if user_answer.lower() == answers[question_index].lower():
    print("Correct!")
    score += 1

else:
    print("Incorrect.")
question_index += 1

print("Quiz complete! You scored", score, "out of", len(questions))

Imaad08 commented 12 months ago

https://imaad08.github.io/student2/2023/10/05/dataAbstraction_IPYNB_2_.html