-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA12_Classe.py
More file actions
29 lines (17 loc) · 833 Bytes
/
A12_Classe.py
File metadata and controls
29 lines (17 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Studente:
numeroStudenti = 0 #variabile di classe condivisa in tutti gli oggetti di tipo Studente
def __init__(self, nome, cognome, classe): #costruttore (self sempre necessario)
self.nome = nome
self.cognome = cognome
self.classe = classe
Studente.numeroStudenti += 1
def show(self): #Metodo (self sempre necessario)
print("Scheda Studente:")
print("Nome: " + self.nome)
print("Cognome: " + self.cognome)
print("Classe: " + self.classe, end = "\n\n")
a = Studente("Alle", "Cristo", "Quinta")
b = Studente("Zip", "Lop", "Univerità")
a.show()
b.show()
print("Nell' istituto sono presenti " + str(Studente.numeroStudenti) + " studenti.")