Classes in Python

Pubblicato il: 29 settembre 2021
sul canale di: Nuruzzaman Faruqui
462
10

Classes are significant in a programming language. It is the heart of object-oriented programming. Python is an object-oriented programming language. As a matter of fact, almost everything is an object in Python. In this lesson, we will learn how to define classes in Python. We will also learn how to create an instance of that class and use the methods of that instance.

The Python code used in this lesson:

class Keyboard:
def definition(self):
print("Keyboard is an input device")

def number_of_keys(self):
print('There are 101 keys')


my_keyboard = Keyboard()
my_keyboard.definition()
my_keyboard.number_of_keys()
my_keyboard.brand = "Logitech"
print(my_keyboard.brand)

new_keyboard = Keyboard()
new_keyboard.definition()
new_keyboard.brand = "Dell"
print(new_keyboard.brand)

‘You are free to copy, edit, use and distribute this code without crediting the author. Enjoy copyright-free content.’ – Nuruzzaman Faruqui.


In questa pagina del sito puoi guardare il video online Classes in Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Nuruzzaman Faruqui 29 settembre 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 462 volte e gli è piaciuto 10 spettatori. Buona visione!