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
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 Cat:
"""Represents a cat.
attributes: name: str, age: int
"""
Write a Cat method, print_cat, that prints cat's information in the following format:
name - ageExample:
Nina - 3
Create a cat, set its attributes and call print_cat
class Student:
"""Represents a student.
attributes: name: str, grade: int, school: str
"""
def print_detail(self):
print(f'Name: {self.name}, School: {self.school}')
Write a method, set_values, that takes a string, name, an integer, grade, and a string, school. The method should assign those arguments to the respective attributes name, grade, and school.
Create a student and call set_values.
class Book:
"""Represents a book.
attributes: title: str, author: str, pages: int
"""
Write a Book method, print_book, that prints book's information in the following format:
Title: book title | Author: book author | Pages: number of pagesExample:
Title: Siddhartha | Author: Hermann Hesse | Pages: 160
Create a book, set its attributes and call print_book
class Phone:
"""Represents a phone.
attributes: brand: str, price: float
"""
def print_info(self):
print(f'Brand: {self.brand}, Price: ${self.price}')
Write a method, setup, that takes two arguments, a string, brand, and an integer, price. The method should assign them to object's brand and price attributes.
Create a phone and call setup.
Define a class, Dog, and define its __init__(self, name, age) method which sets dog's name and age attributes.
Make it possible to compare which dog is older using the > operator. Return True if the left dog is older than the right one, False otherwise.
Create two dogs and compare them using >.
Define a class, GroupAvailability, that receives a list of Member objects and sets its members attribute.
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 FootballPlayer:
"""Represents a football player.
attributes: name: str, goals: int
"""
Write a FootballPlayer method, print_detail, that prints player's information in the following format:
name - goals goalsExample:
Messi - 38 goals
Create a football player, set its attributes and call print_detail