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
class City:
def details(self):
print(f"Name: {self.name}, Population: {self.population}")
c = City()
c.name, c.population = "Tetove", 84770
c.details()
What is printed after the execution of the above program?
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 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 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 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, 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 >.
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.
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 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?