-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestrun.py
More file actions
55 lines (37 loc) · 1 KB
/
Testrun.py
File metadata and controls
55 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
print('Bollean logic')
print('Bollean logic')
print(2 == 2 and 3==3)
print(2 == 2 and 3==4)
print(2 == 2 or 3==4)
print(2 == 2 or 3==3)
print(not 2 == 2 )
print(not 2 != 2 )
# Fetching Jokes From Internet
# Fetching Jokes From Internet
from urllib import request
import json
# Fetching Jokes From Internet
# Fetching Jokes From Internet
url = "https://official-joke-api.appspot.com/random_joke"
r = request.urlopen(url)
# print(r)
print(r.getcode())
# print(r.read())
data = r.read()
jsonData = json.loads(data)
#print(jsonData)
class Joke:
def __init__(self, setup, punchline) -> None:
self.setup = setup
self.punchline = punchline
def __str__(self) -> str:
return f"setup {self.setup} punchline {self.punchline}"
jokes = []
for j in jsonData:
setup = j["setup"]
punchline = j["punchline"]
joke = Joke(setup, punchline)
jokes.append(joke)
print(f"Got {len(jokes)} jokes")
for joke in jokes:
print(joke)