You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -423,7 +423,7 @@ round(3.712, 1)
423
423
424
424
2. Python reports a runtime error when something goes wrong while a program is executing
425
425
426
-
### **Beginner Challenge**: What happens when?
426
+
### **(Optional) Beginner Challenge**: What happens when?
427
427
428
428
Explain in simple terms the order of operations in the following program: when does the addition happen, when does the subtraction happen, when is each functioncalled, etc. Extra credit: What is the final value of radiance?
### (Optional) Methods are functions that belong to objects
850
850
851
-
1. An object packages data together with functions that operate on that data. This is a very common organizational strategy in Python.
851
+
1. You can view an object's attributes (i.e. methods and fields) using `help()` or `dir()`. Some attributes are "private"; you're not supposed to use these directly.
852
+
853
+
``` python
854
+
# More verbose help
855
+
help(str)
856
+
```
857
+
858
+
``` python
859
+
# The short, short version
860
+
dir(my_string)
861
+
```
862
+
863
+
2. An object packages data together with functions that operate on that data. This is a very common organizational strategy in Python.
3. You can view an object's attributes (i.e. methods and fields) using `help()` or `dir()`. Some attributes are "private"; you're not supposed to use these directly.
873
-
874
-
``` python
875
-
# More verbose help
876
-
help(str)
877
-
```
878
-
879
-
``` python
880
-
# The short, short version
881
-
dir(my_string)
882
-
```
883
-
884
-
### **(Optional) Challenge**: Putting it all together
884
+
### **Challenge**: Putting it all together
885
885
886
886
You want to iterate through the `fruits` list in a random order. For each randomly-selected fruit, capitalize the fruit and print it.
Copy file name to clipboardExpand all lines: README.org
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -414,7 +414,7 @@ round(3.712, 1)
414
414
415
415
2. Python reports a runtime error when something goes wrong while a program is executing
416
416
417
-
*** *Beginner Challenge*: What happens when?
417
+
*** *(Optional) Beginner Challenge*: What happens when?
418
418
Explain in simple terms the order of operations in the following program: when does the addition happen, when does the subtraction happen, when is each function called, etc. Extra credit: What is the final value of radiance?
419
419
420
420
#+BEGIN_SRC python
@@ -776,15 +776,26 @@ len("".join(fruits))
776
776
#+END_SRC
777
777
778
778
*** (Optional) Methods are functions that belong to objects
779
-
1. An object packages data together with functions that operate on that data. This is a very common organizational strategy in Python.
779
+
1. You can view an object's attributes (i.e. methods and fields) using ~help()~ or ~dir()~. Some attributes are "private"; you're not supposed to use these directly.
780
+
#+BEGIN_SRC python
781
+
# More verbose help
782
+
help(str)
783
+
#+END_SRC
784
+
785
+
#+BEGIN_SRC python
786
+
# The short, short version
787
+
dir(my_string)
788
+
#+END_SRC
789
+
790
+
2. An object packages data together with functions that operate on that data. This is a very common organizational strategy in Python.
780
791
#+BEGIN_SRC python
781
792
sentence = "Hello world!"
782
793
783
794
# Call the swapcase method on the my_string object
784
795
print(sentence.swapcase())
785
796
#+END_SRC
786
797
787
-
2. You can chain methods into processing pipelines
798
+
3. You can chain methods into processing pipelines
788
799
#+BEGIN_SRC python
789
800
print(sentence.isupper()) # Check whether all letters are uppercase
790
801
print(sentence.upper()) # Capitalize all the letters
@@ -795,17 +806,6 @@ len("".join(fruits))
795
806
sentence.upper().isupper()
796
807
#+END_SRC
797
808
798
-
3. You can view an object's attributes (i.e. methods and fields) using ~help()~ or ~dir()~. Some attributes are "private"; you're not supposed to use these directly.
799
-
#+BEGIN_SRC python
800
-
# More verbose help
801
-
help(str)
802
-
#+END_SRC
803
-
804
-
#+BEGIN_SRC python
805
-
# The short, short version
806
-
dir(my_string)
807
-
#+END_SRC
808
-
809
809
*** COMMENT (Optional) Building longer strings with ~.join()~
810
810
This is replicated in the functions section
811
811
1. Use ~.join()~ to concatenate strings
@@ -822,7 +822,7 @@ This is replicated in the functions section
822
822
print(date)
823
823
#+END_SRC
824
824
825
-
*** *(Optional) Challenge*: Putting it all together
825
+
*** *Challenge*: Putting it all together
826
826
You want to iterate through the ~fruits~ list in a random order. For each randomly-selected fruit, capitalize the fruit and print it.
827
827
1. Which standard library module could help you? https://docs.python.org/3/library/
828
828
2. Which function would you select from that module? Are there alternatives?
0 commit comments