@@ -128,6 +128,18 @@ for person in names:
128
128
for letter in " supercalifragilisticexpialidocious" :
129
129
print (letter.upper())
130
130
```
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
+
131
143
---
132
144
133
145
# While Vs For Loop
@@ -334,6 +346,7 @@ x, y, z = my_func()
334
346
335
347
``` python
336
348
def count_numbers (* args ):
349
+ # return sum(args)
337
350
total = 0
338
351
for num in args:
339
352
total += num
@@ -604,17 +617,17 @@ mercedes.get_wheels()
604
617
```
605
618
---
606
619
607
- # [ fit] The __ init __ function
620
+ # [ fit] The \_\_ init \_\_ function
608
621
609
622
---
610
623
611
- # The __ init __ function
624
+ # The \_\_ init \_\_ function
612
625
613
- All classes have a built-in function called __ init __ ()
626
+ All classes have a built-in function called \_\_ init \_\_ ()
614
627
This is always the first function executed when the class is being initiated into an object.
615
628
616
629
---
617
- # The __ init __ function
630
+ # The \_\_ init \_\_ function
618
631
619
632
``` python
620
633
class Car :
@@ -692,11 +705,6 @@ print(volvo.miles) #AttributeError: 'Car' object has no attribute 'miles'
692
705
693
706
---
694
707
695
- # [ fit] Coding Time
696
- ## Section A
697
-
698
- ---
699
-
700
708
# The pass statement
701
709
702
710
---
@@ -797,13 +805,13 @@ volvo_s90.car_information() # This car is black and has 20000 miles.
797
805
798
806
---
799
807
800
- # The __ init __ function
808
+ # The \_\_ init \_\_ function
801
809
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.
803
811
804
812
---
805
813
806
- # The __ init __ function
814
+ # The \_\_ init \_\_ function
807
815
808
816
``` python
809
817
class Volvo (Car ):
@@ -812,13 +820,13 @@ class Volvo(Car):
812
820
813
821
---
814
822
815
- # The __ init __ function
823
+ # The \_\_ init \_\_ function
816
824
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.
818
826
819
827
---
820
828
821
- # The __ init __ function
829
+ # The \_\_ init \_\_ function
822
830
823
831
``` python
824
832
class Volvo (Car ):
@@ -850,9 +858,11 @@ class Volvo(Car):
850
858
class Volvo (Car ):
851
859
def __init__ (self , colour , miles , seats ):
852
860
super ().__init__ (colour, miles)
861
+
853
862
# Adding another property to the child class
854
863
self .seats = seats
855
864
865
+
856
866
volvo_s90 = Volvo(" black" , 20000 , 5 )
857
867
print (volvo_s90.seats)
858
868
```
@@ -872,12 +882,18 @@ class Volvo(Car):
872
882
print (" This car is " + self .colour + " , has " + str (self .miles) +
873
883
" miles and " + str (self .seats) + " seats." )
874
884
885
+
875
886
volvo_s90 = Volvo(" black" , 20000 , 5 )
876
887
volvo_s90.more_car_info()
877
888
```
878
889
879
890
---
880
891
892
+ # [ fit] Coding Time
893
+ ## Section A
894
+
895
+ ---
896
+
881
897
### Questions?
882
898
### go to sli.do #ihfcode
883
899
0 commit comments