Skip to content

Commit 5558232

Browse files
committed
add live coded exercises for day 1
1 parent fa1d777 commit 5558232

8 files changed

Lines changed: 54 additions & 0 deletions

File tree

pyworkshop/.DS_Store

-6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# this will throw an error
2+
try:
3+
int("a")
4+
except ValueError as e:
5+
print("oops, you can't do that!", e)
6+
7+
print("this is the end of my program")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
greetings = ["Hello", "Bonjour", "Hola"]
2+
3+
for greeting in greetings:
4+
print(f"{greeting}, World!")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def mystery():
2+
num = 10 * 3
3+
4+
if num == 10:
5+
print("condition 10")
6+
num = num * 10
7+
elif num == 30:
8+
print("condition 30")
9+
num = num * 30
10+
11+
print(f"num was {num}")
12+
return num
13+
14+
print(mystery())
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = "Nina"
2+
print(name)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def upper_case_name(name):
2+
return name.upper()
3+
4+
if __name__ == "__main__":
5+
name = "Nina"
6+
name_upper = upper_case_name(name)
7+
print(f"Upper case name is {name_upper}")
8+
print("dunder name", __name__)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import name_lib
2+
3+
my_name = "Fred"
4+
upper_name = name_lib.upper_case_name(my_name)
5+
6+
print(f"In my own code, upper name is {upper_name}")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import requests
2+
3+
api_url = "http://shibe.online/api/shibes?count=1"
4+
5+
params = {"count": 10}
6+
response = requests.get(api_url, params=params)
7+
8+
status_code = response.status_code
9+
print("status code: ", status_code)
10+
11+
response_json = response.json()
12+
print(response_json)
13+
print(response.url)

0 commit comments

Comments
 (0)