diff --git a/README.md b/README.md
index 00cbbf7..8e688e0 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-# Code in Place Spring 2023 - Stanford University
+# Code in Place Spring 2024 - Stanford University
-Extra suplemental materials dedicated to Code in Place Spring 2023 with Stanford University
+Extra suplemental materials dedicated to Code in Place Spring 2024 with Stanford University
Topics to be covered:
-## Input Arguments (Week 2: May 05, 2023) ##
+## Input Arguments (Week 2: May 03, 2024) ##
User Input Prompt: remember all data types are still in string
@@ -15,7 +15,7 @@ def main():
```
-## Console Programming (Week 3: May 12, 2023) ##
+## Console Programming (Week 3: May 10, 2024) ##
### Conditional Branching ###
@@ -23,67 +23,123 @@ def main():
```python
def main():
+ MERCURY_GRAVITY = (37.6 / 100)
+ VENUS_GRAVITY = (88.9 / 100)
+ MARS_GRAVITY = (37.8 / 100)
+ JUPITER_GRAVITY = (236 / 100)
+ SATURN_GRAVITY = (108.1 / 100)
+ URANUS_GRAVITY = (81.5 / 100)
+ NEPTUNE_GRAVITY = (114 / 100)
+
earthWeight = float(input("Enter the object weight: "))
planetName = input("Enter a planet name: ")
if (planetName == "Mercury"):
- planetWeight = float(earthWeight) * (37.6 / 100)
+ planetWeight = float(earthWeight) * MERCURY_GRAVITY
elif (planetName == "Venus"):
- planetWeight = float(earthWeight) * (88.9 / 100)
+ planetWeight = float(earthWeight) * VENUS_GRAVITY
elif (planetName == "Mars"):
- planetWeight = float(earthWeight) * (37.8 / 100)
+ planetWeight = float(earthWeight) * MARS_GRAVITY
elif (planetName == "Jupiter"):
- planetWeight = float(earthWeight) * (236 / 100)
+ planetWeight = float(earthWeight) * JUPITER_GRAVITY
elif (planetName == "Saturn"):
- planetWeight = float(earthWeight) * (108.1 / 100)
+ planetWeight = float(earthWeight) * SATURN_GRAVITY
elif (planetName == "Uranus"):
- planetWeight = float(earthWeight) * (81.5 / 100)
+ planetWeight = float(earthWeight) * URANUS_GRAVITY
elif (planetName == "Neptune"):
- planetWeight = float(earthWeight) * (114 / 100)
+ planetWeight = float(earthWeight) * NEPTUNE_GRAVITY
else:
- planetWeight = 0
+ planetWeight = -1.0 # Why put a negative value here?
```
- 2. MATCH-CASE Statement (Require Python 3.10 or above)
+ 2. IF Statement
```python
def main():
+ MERCURY_GRAVITY = (37.6 / 100)
+ VENUS_GRAVITY = (88.9 / 100)
+ MARS_GRAVITY = (37.8 / 100)
+ JUPITER_GRAVITY = (236 / 100)
+ SATURN_GRAVITY = (108.1 / 100)
+ URANUS_GRAVITY = (81.5 / 100)
+ NEPTUNE_GRAVITY = (114 / 100)
+
+ earthWeight = float(input("Enter the object weight: "))
+ planetName = input("Enter a planet name: ")
+ planetWeight = -1 # Why put a negative value here?
+
+ if (planetName == "Mercury"):
+ planetWeight = float(earthWeight) * MERCURY_GRAVITY
+
+ if (planetName == "Venus"):
+ planetWeight = float(earthWeight) * VENUS_GRAVITY
+
+ if (planetName == "Mars"):
+ planetWeight = float(earthWeight) * MARS_GRAVITY
+
+ if (planetName == "Jupiter"):
+ planetWeight = float(earthWeight) * JUPITER_GRAVITY
+
+ if (planetName == "Saturn"):
+ planetWeight = float(earthWeight) * SATURN_GRAVITY
+
+ if (planetName == "Uranus"):
+ planetWeight = float(earthWeight) * URANUS_GRAVITY
+
+ if (planetName == "Neptune"):
+ planetWeight = float(earthWeight) * NEPTUNE_GRAVITY
+```
+
+
+
+ 3. MATCH-CASE Statement (Require Python 3.10 or above)
+
+```python
+def main():
+ MERCURY_GRAVITY = (37.6 / 100)
+ VENUS_GRAVITY = (88.9 / 100)
+ MARS_GRAVITY = (37.8 / 100)
+ JUPITER_GRAVITY = (236 / 100)
+ SATURN_GRAVITY = (108.1 / 100)
+ URANUS_GRAVITY = (81.5 / 100)
+ NEPTUNE_GRAVITY = (114 / 100)
+
earthWeight = float(input("Enter the object weight: "))
planetName = input("Enter a planet name: ")
match planetName:
case "Mercury":
- planetWeight = float(earthWeight) * (37.6 / 100)
+ planetWeight = float(earthWeight) * MERCURY_GRAVITY
case "Venus":
- planetWeight = float(earthWeight) * (88.9 / 100)
+ planetWeight = float(earthWeight) * VENUS_GRAVITY
case "Mars":
- planetWeight = float(earthWeight) * (37.8 / 100)
+ planetWeight = float(earthWeight) * MARS_GRAVITY
case "Jupiter":
- planetWeight = float(earthWeight) * (236 / 100)
+ planetWeight = float(earthWeight) * JUPITER_GRAVITY
case "Saturn":
- planetWeight = float(earthWeight) * (108.1 / 100)
+ planetWeight = float(earthWeight) * SATURN_GRAVITY
case "Uranus":
- planetWeight = float(earthWeight) * (81.5 / 100)
+ planetWeight = float(earthWeight) * URANUS_GRAVITY
case "Neptune":
- planetWeight = float(earthWeight) * (114 / 100)
+ planetWeight = float(earthWeight) * NEPTUNE_GRAVITY
case other:
- planetWeight = 0.0
+ planetWeight = -1.0 # Why put a negative value here?
```
@@ -92,60 +148,39 @@ def main():
- Notice that both "+" and "," can be used interchangably
- Concatenate multiple strings with + (plus) or , (comma)
- All concatenated items have to be converted to the same data type (string)
+
+ Examples
+
```python
planetName = "Mars"; planetWeight = 175.26
print("The weight on " + planetName + ": " + str(marsWeight))
print("The weight on " , planetName + ": " , str(marsWeight))
```
+
+
2. Reference
- Notice the ```.format(,)``` patten
- Unlike concatenation method, this method requires no string conversion
- Use the {} (curly brackets) to place your variable
+
+ Examples
+
```python
planetName = "Mars"; planetWeight = 175.26
print("The weight on {}: {}".format(planetName, planetWeight))
```
+
+
3. F-word
- Notice the f letter inside print()
- Similar to method 2 (reference), but now variable name is placed inside the curly brackets
- Likewise, no variable casting (conversion) is needed
+
+ Examples
+
```python
planetName = "Mars"; planetWeight = 175.26
print(f"The weight on {planetName}: {planetWeight}")
```
-
-## Graphics (Week 4: May 19, 2023) ##
-
-### Functions with Parameters ###
-
- 1. Single Output Return
-
-```python
-def single_output_function(input_1, input_2, input_3):
- output = input_1 * input_2 * input_3
- return output
-```
-
-
- 2. Multiple Outputs Return
-
-```python
-def multi_output_function(input_1, input_2):
- # Begin by declaring def, brackets, and colon sign (:)
- output_1 = input_1 + input_2
- output_2 = input_1 * input_2
-
- # The correct word is return, NOT result
- return output_1, output_2
-```
-
-
-## Animation (Week 5: May 26, 2023) ##
-
- - Coming Soon
-
-## Data Structures: Containers (Week 6: June 02, 2023) ##
-
- - Coming Soon