GUVI --> 100 Days Of Python Advanced
Assignment:
1.
class Calculator:
def add(self, a, b):
return a + b
def subtract(self, a, b):
return a - b
def multiply(self, a, b):
return a * b
def divide(self, a, b):
if b == 0:
raise ValueError("Division by zero is not allowed")
return a / b
a, b = map(int, input().split())
calc = Calculator()
print(calc.add(a, b))
print(calc.subtract(a, b))
print(calc.multiply(a, b))
print(calc.divide(a, b))
2.
import json
def find_matching_people(json_str):
people = json.loads(json_str)
matching_names = [person["name"] for person in people if person["age"] >= 30 and person["nationality"] == "USA"]
if matching_names:
print(" ".join(matching_names))
else:
print("No matching people found")
json_str = input()
find_matching_people(json_str)