Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7239bd9

Browse files
oop
1 parent 19f4c06 commit 7239bd9

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

‎data_structures/dicts.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
print(student)
4242
age = student.pop('age') # Removes and return the value
4343
print(age)
44+
print(student)
4445

4546

4647
print('\n')

‎loops_and_conditionals/conditionals_booleans.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
# Empty sequence IE. '', (), []
117117
# Empty map/dict {}
118118

119-
condition = {} # Try all the above!
119+
condition = None # Try all the above!
120120

121121
if condition:
122122
print('This is True')

‎loops_and_conditionals/while.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
else:
4444
break
4545

46+
print(name.lower())
4647

4748

4849
# --------------------> <-------------------- #

‎oop/class.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Student:
2+
3+
year = 1
4+
num_of_students = 0
5+
6+
def __init__(self, first, last, email):
7+
self.first = first
8+
self.last = last
9+
self.email = email
10+
Student.num_of_students += 1
11+
12+
def fullname(self):
13+
return '{} {}'.format(self.first, self.last)
14+
15+
s1 = Student('Alessandro', 'Versace', 'aleversace98@gmail.com')
16+
s2 = Student('Me', "NotMe", "menotme@gmail.com")
17+
18+
print(s1.fullname())
19+
print('\n')
20+
21+
print(s2.__dict__)
22+
print('\n')
23+
24+
print(Student.__dict__)
25+
s1.year = 2
26+
print('\n')
27+
28+
print(s1.__dict__)
29+
print('\n')
30+
31+
print(Student.num_of_students)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /