Define a class, Member, with its __init__(self, name: str, available_hours: set) method, which sets members name and available_hours attributes.
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 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 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 Cat:
"""Represents a cat.
attributes: name: str, age: int, color: str
"""
def print_info(self):
print(f'Name: {self.name}, Age: {self.age}, Color: {self.color}')
Write a method named set, which takes one string and two integers as arguments, name, age, and color. The method should set three attributes on the object: name, age, and color, and assign the corresponding arguments to them.
Create a cat and call the set method.
class Bird:
def set_attributes(self, species, sound):
self.species = species
self.sound = sound
def sing(self):
print(self.sound)
owl = Bird()
owl.set_attributes("Owl", "hoot")
owl.sing()
class Student:
"""Represents a student.
attributes: first_name: str, last_name: str, grade: float
"""
Write a Student method, print_student, that prints student's information in the following format:
full name - gradeExample:
Sara Aliu - 8.6
Create a student, set its attributes and call print_student
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 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 base class Employee with __init__(self, name, employee_id) that sets name and employee_id attributes.