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 Movie:
"""Represents a movie.
attributes: title: str, year: int, genre: str
"""
def display(self):
print(f'Title: {self.title}, Year: {self.year}, Genre: {self.genre}')
Write a method, set_movie(title: str, year: int, genre: str), which sets objects title, year, and genre attributes.
Create a movie and set its attributes.
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 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
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
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.
Define a base class Shape with __init__(self, name) method that sets the name attribute.
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, Book, with its __init__(self, title, author, year, available) method, which sets title (str), author (str), year (int), and available (bool) attributes.
class Player:
def print_player(self):
print(self.name)
def set_player(self, name, goals):
self.name = name
self.goals = goals
p = Player()
p.set_player("Rod", 57)
p.print_player()
What is printed after the execution of the above program?