en

Cerca

Heus ací els resultats de la cerca.

2.8 Composition vs Inheritance - two ways to the same destination
39 Resultats, Darrera modificació:
network card; * a Hovercraft **has a** specific engine. Composition is the process of composing an ... <code python> class Car: def __init__(self, engine): self.engine = engine class GasEngine: def __init__(self, horse_power): self.hp = horse_power
2.9 Inheriting properties from built-in classes
19 Resultats, Darrera modificació:
ilt-in class in order to get a new class that can enrich the parent's attributes or methods. As a resu... serial numbers of sold tickets. Sound reasonable enough? Your new class will be based on the Pytho... ch is responsible for appending an element to the end of the list. This method follows the previous wa... to validate it. We'll use the IBAN Validator to ensure that our banking app dictionary contains only
2.7 Encapsulation
17 Resultats, Darrera modificació:
= 2.7 Encapsulation == Attribute encapsulation Encapsulation is one of the fundamental concepts in object-oriented programming (amongst i... ds that work on those attributes within a class. Encapsulation is used to hide the **attributes** ins
2.5 Different faces of Python methods
10 Resultats, Darrera modificació:
may allow you to create a watch with a dedicated engraving (text). As this is an extra option, the watch with the engraving should be created using an alternative con... ''%%__init__%%'' method should not allow ordering engravings; * the regular ''%%__init__%%'' method ... propriate class variable; The text intended to be engraved should follow some restrictions: * it sh
3.1 Advanced techniques of creating and serving exceptions
9 Resultats, Darrera modificació:
rt introduction When Python executes a script and encounters a situation that it cannot cope with, it:... Error'' exception – raised when a Unicode-related encoding or decoding error occurs. It is a subclass ... The UnicodeError has attributes that describe an encoding or decoding error. * **encoding** – the name of the encoding that raised the error. * **re
2.4 Decorators
5 Resultats, Darrera modificació:
) could reference an object (own_function) in its enclosing scope thanks to the closure. == Decorator... different materials. Note that our decorator is enriched with one more function to make it able to h... rator calls your function; * when your function ends it execution, the inner_decorator takes over co... s. * Apply your decorator to those functions to ensure that the time of the function executions can
2.6 Abstract classes
5 Resultats, Darrera modificació:
become familiar with the error messages you would encounter in such a situation. == LAB === Objective... ate an abstract class representing a scanner that enforces the following methods: * **scan_documen... ate an abstract class representing a printer that enforces the following methods: * **print_docume... resposta <code python ; resposta1.py> #!/usr/bin/env python # -*- coding: utf-8 -* import abc class
1.1 Classes, Instances, Attributes, Methods — introduction
3 Resultats, Darrera modificació:
plications because it allows programmers to model entities representing real-life objects. Moreover, O... son of inheritance and composition; * attribute encapsulation; * exception chaining; * object pe... ef turn_on(self): print("el mòbil %s està engegat" % (self.number) ) def turn_off(sel
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
3 Resultats, Darrera modificació:
each time? === reposta <code python> #!/usr/bin/env python # -*- coding: utf-8 -* class Scanner: ... _', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdec
4.2 Serialization of Python objects using the pickle module
3 Resultats, Darrera modificació:
rence, so the same restrictions in the unpickling environment apply. Note that none of the class’s cod... ier version of the class. Hence, your role is to ensure that the environment where the class or function is unpickled is able to import the class or func
2.1 Python core syntax
2 Resultats, Darrera modificació:
method for a Python core operation, as the tables enumerate the most popular operators and functions t... special methods built-in in Python contains more entities. For more information, refer to https://doc
2.3 Extended function argument syntax
2 Resultats, Darrera modificació:
presented invocations of the **print()** function end correctly, and the argument values are passed to... rs: <code python> def print(self, *args, sep=' ', end='\n', file=None): </code> == Extended functio
4.1 Shallow and deep copy operations
2 Resultats, Darrera modificació:
identity'? Why are the object value and label not enough? The built-in ''id()'' function returns the ... type of candy. Each type of candy contains a key entitled 'weight', which should lead you to the tota
5.1 Metaprogramming
2 Resultats, Darrera modificació:
re classes are instantiated. Metaclasses usually enter the game when we program advanced modules or f... completing classes with a method (if missing) to ensure that all your classes are equipped with a met
1.2 Working with class and instance data – instance variables
1 Resultats, Darrera modificació:
, drake, hen, chicken: print(poultry.species, end=' ') if poultry.species == 'duck': p
4.3 Making Python objects persistent using the shelve module
1 Resultats, Darrera modificació: