Skip to content

Commit 1b19d13

Browse files
committed
classes and libs
1 parent afee487 commit 1b19d13

16 files changed

+143
-0
lines changed

2_classes-and-objects/class1.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
class Rolex:
2+
3+
def __init__(self):
4+
pass
5+
# attributes
6+
chapati_size: str
7+
number_of_eggs: int
8+
withSalt: bool
9+
toppings: bool
10+
11+
def price(self, tax):
12+
total =0.0
13+
if self.chapati_size == "large":
14+
total = total + 3000
15+
elif self.chapati_size == "medium":
16+
total = total + 2000
17+
else:
18+
total = total + 1000
19+
20+
total = total + self.number_of_eggs * 500
21+
22+
if self.toppings:
23+
total = total + 1000
24+
25+
total = total * tax
26+
27+
return total
28+
29+
a_rolex: Rolex = Rolex()
30+
a_rolex.chapati_size = "large"
31+
a_rolex.number_of_eggs = 3
32+
a_rolex.withSalt = True
33+
a_rolex.toppings = False
34+
35+
36+
print(a_rolex.price(1.18))
37+
# print(a_rolex)
38+
# print(a_rolex.chapati_size)
39+

libs/.cache

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"access_token": "BQDFNkAQBL5m51k888OxkZtTDTHUgiOGb94qgGCDmitNk3XxAXUfnCtcwye47KHRWLlznn4-fXAXMDa2nPjX91Iw_VhCTIBsWsKhw3kS8C7B4-C_BmhP", "token_type": "Bearer", "expires_in": 3600, "expires_at": 1675503672}

libs/__pycache__/lib1.cpython-311.pyc

402 Bytes
Binary file not shown.

libs/__pycache__/lib7.cpython-311.pyc

845 Bytes
Binary file not shown.

libs/__pycache__/libx.cpython-311.pyc

810 Bytes
Binary file not shown.

libs/lib1.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Pypi -
2+
3+
import cowsay
4+
import sys
5+
6+
7+
if len(sys.argv) ==2:
8+
#cowsay.goat("Hello"+ sys.argv[1])
9+
cowsay.dragon("Hello"+ sys.argv[1])

libs/lib2.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import requests
2+
3+
response = requests.get("https://ucu.ac.ug")
4+
5+
#print(response)
6+
#print(dir(response))
7+
#print(help(response))
8+
9+
print(response.text)

libs/lib3.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import requests
2+
3+
response = requests.get("https://i.stack.imgur.com/WyyDdl.png")
4+
5+
# with open("pyth.png", "wb") as fil:
6+
# fil.write(response.content)
7+
8+
print(response.ok)
9+
10+
# httpbin.org

libs/lib4.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import requests
2+
3+
4+
# response = requests.get("https://httpbin.org/get?page=2&count=15")
5+
6+
7+
# payload = {"page": 2, "count": 15}
8+
# response = requests.get("https://httpbin.org/get",params=payload)
9+
10+
# print(response.url)
11+
12+
payload = {"username": "joe", "password": "testing"}
13+
response = requests.post("https://httpbin.org/post",data=payload)
14+
15+
# print(response.json())
16+
17+
dct = response.json()
18+
19+
print(dct['form'])

libs/lib5.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import requests
2+
3+
# response = requests.get("https://httpbin.org/basic-auth/joe/testing", auth=("joe", "testing4"))
4+
5+
response = requests.get("https://httpbin.org/delay/3", timeout=2)
6+
7+
print(response)

libs/lib6.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import spotipy
2+
from spotipy.oauth2 import SpotifyClientCredentials
3+
4+
birdy_uri = 'https://open.spotify.com/artist/6d7TH1WmN4YI15WAygkuMR?si=e0NqsQKQRnCJlmJKlgBPVw'
5+
spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials(client_id="43cb3cca0cce496ca6c701c24c975978", client_secret="3b29696531a74083bbce7e4b2954ec10"))
6+
7+
results = spotify.artist_albums(birdy_uri, album_type='album')
8+
albums = results['items']
9+
while results['next']:
10+
results = spotify.next(results)
11+
albums.extend(results['items'])
12+
13+
for album in albums:
14+
print(album['name'])

libs/lib7.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def main():
2+
studentName("John")
3+
studentHall("Mitchell")
4+
5+
def studentName(name):
6+
print(f"Hello, {name}")
7+
8+
def studentHall(hall):
9+
print(f"Hall, {hall}")
10+
11+
if __name__ == "__main__":
12+
main()

libs/lib8.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import sys
2+
from lib7 import studentHall
3+
4+
if len(sys.argv) == 2:
5+
studentHall(sys.argv[1])
6+

libs/libx.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def main():
2+
studentName("jphn")
3+
studentHall("Sabit")
4+
5+
def studentName(name):
6+
print(f"Hello,{name}")
7+
8+
def studentHall(hall):
9+
print(f"Hall, {hall}")
10+
11+
if __name__ == "__main__":
12+
main()

libs/liby.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sys
2+
from libx import studentHall
3+
4+
if len(sys.argv) == 2:
5+
studentHall(sys.argv[1])

libs/pyth.png

27.4 KB
Loading

0 commit comments

Comments
 (0)