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 ==.
class Laptop:
"""Represents a laptop.
attributes: brand: str, ram: int, storage: int
"""
def print_specs(self):
print(f'Brand: {self.brand}, RAM: {self.ram}GB, Storage: {self.storage}GB')
Write method, configure, to set brand, ram, and storage.
Create a laptop and call configure.
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.
class Movie:
"""Represents a movie.
attributes: title: str, year: int
"""
Write a Movie method, print, that prints movie's information in the following format:
title (year)Example:
Inception (2010)
Create a movie, set its attributes and call print
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 >=.
Define a class, Product, and define its __init__(self, name: str, price: int) method which sets course's name and price attributes.
Allow comparison of products using the != operator. Return True if the products do not cost the same; otherwise, return False.
Create two products and compare them using !=.
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 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 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
Define a base class Employee with __init__(self, name, employee_id) that sets name and employee_id attributes.