class Laptop:
"""Represents a laptop.
attributes: brand: str, ram: int (in GB)
"""
Write a Laptop method, print_info, that prints laptop's information in the following format:
brand - RAMGBExample:
Dell - 16GB
Create a laptop, set its attributes and call print_info
class Country:
"""Represents a country.
attributes: name: str, population: int
"""
def show(self):
print(f'Country: {self.name}, Population: {self.population}')
Write method, set_country to set name and population.
Create a country and call set_country.
class Phone:
"""Represents a phone.
attributes: model: str, price: float
"""
Write a Phone method, print_details, that prints phone's information in the following format:
model - $priceExample:
iPhone 13 - $999.99
Create a phone, set its attributes and call print_details
Define a class, City, and define its __init__(self, name: str, population: int, country: str) method which sets city's name, population and country attributes.
Enable comparison between cities using >=.
Return True if the left city's population is greater than or equal to the right city's;
otherwise, return False.
Create two cities and compare them using >=.
class City:
"""Represents a city.
attributes: name: str, population: int, country: str
"""
Write a City method, print_city, that prints city's information in the following format:
Name: city's name, Country: city's country | population peopleExample:
Name: Tirane, Country: Albania | 600000 people
Create a city, set its attributes and call print_city
Define a class, Student, and define its __init__(self, name: str, grade: int) method which sets dog's name and grade attributes.
Make it possible to compare if two students have the same grade using ==. Return True if students have the same grade, False otherwise.
Create two students and compare them using ==.
Define a class, Laptop, and define its __init__(self, brand: str, storage: int) method which sets course's brand and storage attributes.
Enable comparison of laptops using the <= operator. Return True if the left laptop has equal or smaller storage capacity than the right one; otherwise, return False.
Create two laptops and compare them using <=.
class House:
"""Represents a house.
attributes: address: str, rooms: int, area: int
"""
def show_info(self):
print(f'Address: {self.address}, Area: {self.area} m square')
Write a House method. set_house_attrs, that sets all three attributes.
Create a house and call set_house_attrs.
Define a class, Book, and define its __init__(self, title: str, pages: int) method which sets dog's title and pages attributes.
Make it possible to compare which book has more pages using < operator. Return True if the left book has less pages than the right one, False otherwise.
Create two books and compare them using <.
class Book:
"""Represents a book.
attributes: title: str, pages: int
"""
def print_book(self):
print(f'Title: {self.title}, Pages: {self.pages}')
Write a method, set(title: str, pages: int), that sets object's title and pages attributes.
Create a book and set its attributes.