8000 tweaks · uceimmp/python@3268401 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3268401

Browse files
committed
tweaks
1 parent cd4e2f5 commit 3268401

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

session_10/slides/session_10.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ for person in names:
128128
for letter in "supercalifragilisticexpialidocious":
129129
print(letter.upper())
130130
```
131+
132+
---
133+
134+
# While Loops
135+
136+
```python
137+
guess = None
138+
while guess != 4:
139+
# Continues to ask for a number until you enter 4
140+
guess = int(input("What's your number? "))
141+
```
142+
131143
---
132144

133145
# While Vs For Loop
@@ -334,6 +346,7 @@ x, y, z = my_func()
334346

335347
```python
336348
def count_numbers(*args):
349+
# return sum(args)
337350
total = 0
338351
for num in args:
339352
total += num
@@ -604,17 +617,17 @@ mercedes.get_wheels()
604617
```
605618
---
606619

607-
# [fit]The __ init __ function
620+
# [fit]The \_\_init\_\_ function
608621

609622
---
610623

611-
# The __ init __ function
624+
# The \_\_init\_\_ function
612625

613-
All classes have a built-in function called __init__()
626+
All classes have a built-in function called \_\_init\_\_()
614627
This is always the first function executed when the class is being initiated into an object.
615628

616629
---
617-
# The __init __ function
630+
# The \_\_init\_\_ function
618631

619632
```python
620633
class Car:
@@ -692,11 +705,6 @@ print(volvo.miles) #AttributeError: 'Car' object has no attribute 'miles'
692705

693706
---
694707

695-
# [fit] Coding Time
696-
## Section A
697-
698-
---
699-
700708
# The pass statement
701709

702710
---
@@ -797,13 +805,13 @@ volvo_s90.car_information() # This car is black and has 20000 miles.
797805

798806
---
799807

800-
# The __ init __ function
808+
# The \_\_init\_\_ function
801809

802-
When you add the __ init __ function to the child class, it no longer inherits the parents.
810+
When you add the \_\_init\_\_ function to the child class, it no longer inherits the parents.
803811

804812
---
805813

806-
# The __ init __ function
814+
# The \_\_init\_\_ function
807815

808816
```python
809817
class Volvo(Car):
@@ -812,13 +820,13 @@ class Volvo(Car):
812820

813821
---
814822

815-
# The __ init __ function
823+
# The \_\_init\_\_ function
816824

817-
To keep the parent's __ init __ function, add a call to the parent's __ init __ function.
825+
To keep the parent's \_\_init\_\_ function, add a call to the parent's \_\_init\_\_ function.
818826

819827
---
820828

821-
# The __ init __ function
829+
# The \_\_init\_\_ function
822830

823831
```python
824832
class Volvo(Car):
@@ -850,9 +858,11 @@ class Volvo(Car):
850858
class Volvo(Car):
851859
def __init__(self, colour, miles, seats):
852860
super().__init__(colour, miles)
861+
853862
#Adding another property to the child class
854863
self.seats = seats
855864

865+
856866
volvo_s90 = Volvo("black", 20000, 5)
857867
print(volvo_s90.seats)
858868
```
@@ -872,12 +882,18 @@ class Volvo(Car):
872882
print("This car is " + self.colour + ", has " + str(self.miles) +
873883
" miles and " + str(self.seats) + " seats.")
874884

885+
875886
volvo_s90 = Volvo("black", 20000, 5)
876887
volvo_s90.more_car_info()
877888
```
878889

879890
---
880891

892+
# [fit] Coding Time
893+
## Section A
894+
895+
---
896+
881897
### Questions?
882898
### go to sli.do #ihfcode
883899

0 commit comments

Comments
 (0)
0