Create two classes, Library and Book.
Create a library, library and add some books to library.books dictionary
whose keys are characters and values are list of books whose title start with that character.
Example:
{'a': [<Book whose title is 'Ali baba'>, ...], 'o': [<Book whose title is 'Of Mice and Men'>, ...]}
Add a new book that starts with 's'.
Print the first book that starts with 's'.
Create two classes, Bird and Nest.
Create a bird, with species: str and nest: Nest attributes.
Create two classes, Zoo and Animal.
Create some animals with one attribute, name.
Create a zoo and add created animals to its animals: set attribute.
Add one more animal to the zoo.
Create two classes, Company and Employee.
Create some employees and assign their names.
Create two companies, add an employees: set attribute and add some employees to each of the companies.
Check if there's any employee working in both companies and print them.
class Room:
pass
r = Room()
r.name = "Living Room"
r.lights_on = False
r.lights_on = True
What is the value of the following expressions at the end of execution of the above script?
| r.name: | ||
| r.lights_on: |
class Movie:
"""Represents a movie."""
movie = Movie()
movie.title, movie.year = "The Shawshank Redemption", 1994
Given the above script
| What is name of the defined class: | ||
| What variable is the only class instance assigned to: | ||
| How many attributes does the only class instance have: | ||
| What is the first defined attribute name: | ||
| What is the second defined attribute name: | ||
| What is value of title movie attribute: | ||
| What is value of year movie attribute: |
Create a class named Person
Create an instance of Person and assign it to friend
Assign two attributes to friend, name and age, with values "Elira" and 29 respectively.
Create a class named Book
Create an instance of Book and assign it to book
Assign two attributes to book, title and pages, with values "Of Mice And Men" and 120 respectively.
Create one class, Dog.
Create a dog, dad, with name: str attribute
Create a dog, puppy, with name: str and parent: Dog attributes
Create a class named Computer
Create an instance of Computer and assign it to pc
Assign two attributes to pc, brand and ram, with values "Lenovo" and 16 respectively.