Skip to content

Commit 7f747d5

Browse files
committed
updates
1 parent 0d0c212 commit 7f747d5

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

labs/coding-103-python-json/5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ for auto in cars["sports"]:
4343
```
4444

4545
Here's the output from running our script parsing each JSON data with the old and new way.
46-
![](/posts/files/coding-103-python-json/assets/images/loops.png)<br/><br/>
46+
![](/posts/files/coding-103-python-json/assets/images/loops-ex.png)<br/><br/>
4747

4848

4949
Let's review what we've learned so far! Review the code below and see if you can figure out what will be printed to the screen.

labs/coding-103-python-json/6.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
A function is a block of code that is run only when it's explicitly called. For example, print() is a function written in Python that you've called many times. Functions are written to modularize code to make it easy to read, easier to debug because it's located in one place and to reuse. Essentially, you don't want to write code over and over again that does the same thing. Instead you would put it into a function and then call that function whenever you need it.
44

5-
Let's look at the structure of a function, then we'll look at a simple example. In Python a function is defined in the follow manner shown below. The keyword **def** specifies that a function is defined which is then followed by the name of the function and optional arguments that are passed into it.
5+
Let's look at the structure of a function, then we'll look at a simple example. In Python a function is defined in the follow manner shown below. The keyword **def** specifies that a function is defined which is then followed by the name of the function and optional arguments that are passed into it.<br/><br/>
66

7-
![](/posts/files/coding-103-python-json/assets/images/function-struct.png)
8-
9-
Let's look at some simple examples of functions. The first function named **my_function** simply prints a statement. The second function **brett** takes an argument called **val** which it passes to the function **range** and uses for looping.
10-
![](/posts/files/coding-103-python-json/assets/images/function-ex.png)
7+
![](/posts/files/coding-103-python-json/assets/images/function-struct.png)<br/><br/>
118

9+
Let's look at some simple examples of functions. The first function named **my_function** simply prints a statement. The second function **brett** takes an argument called **val** which it passes to the function **range** and uses for looping.<br/><br/>
10+
![](/posts/files/coding-103-python-json/assets/images/function-ex.png)<br/><br/>
1211

1312
Now let's look at these simple functions in a script to see how they're called. When this script is run, starting from the top of the script, the Python interpretor looks at what it should run now. It sees the call to print and executes that. It then sees the next two defined functions, makes note of them, but does not run them because they are not explicitly called. Continuing down the script it then sees the call to **function my_function** and executes it. Finally, it sees the call to **function brett** with the argument of 5 passed in and executes it.
1413
```python
@@ -25,7 +24,8 @@ def brett(val):
2524
my_function()
2625
brett(5)
2726
```
28-
As a result the output occurs as shown below.
27+
<br/><br/>
28+
As a result the output occurs as shown below.<br/><br/>
2929
![](/posts/files/coding-103-python-json/assets/images/function-out.png)
3030

3131

@@ -112,7 +112,7 @@ You should see a result like the following. For purposes of brevity some record
112112

113113

114114
## Give it a Try
115-
* Open file **json_parse-1.py** . Create and call two functions that parse the JSON data. You may use the code you wrote in Step 5 to complete the functions. Run the code.
115+
* Open file **json_parse-1.py** . write and call two functions that parse the JSON data. You may use the code you wrote in Step 5 to complete the functions. Run the code.
116116
* Run the file \DevNetCode\&lt;your-name&gt;\coding-skills-sample-code\coding102-REST-python-ga\get-network-devices.py . Review the JSON data printed. Then open the file and modify it to print out other data. Run the code.
117117

118118

Loading
Loading

0 commit comments

Comments
 (0)