Skip to content

Commit ee9676c

Browse files
committed
stepic ex
1 parent 7b30643 commit ee9676c

File tree

5 files changed

+1885
-0
lines changed

5 files changed

+1885
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

stepic/any_all.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
def valid_rgb(rgb):
2+
#check if rgb input tuple is within 0-255
3+
for val in rgb:
4+
if not 0 <= val <= 255:
5+
return False
6+
return True
7+
8+
9+
# print(valid_rgb((255, 100, 255)))
10+
# print(valid_rgb((255, 100, 256)))
11+
12+
def valid_rgb(rgb):
13+
#check if rgb input tuple is within 0-255
14+
valid = [
15+
0 <= val <= 255
16+
for val in rgb
17+
]
18+
return all(valid)
19+
20+
# print(valid_rgb((255, 100, 255)))
21+
# print(valid_rgb((255, 100, 256)))
22+
23+
24+
def valid_rgb(rgb):
25+
#check if rgb input tuple is within 0-255
26+
return all(
27+
0 <= val <= 255
28+
for val in rgb
29+
)
30+
31+
# print(valid_rgb((255, 100, 255)))
32+
# print(valid_rgb((255, 100, 256)))
33+
34+
35+
def contains_numbers(input):
36+
for char in input:
37+
if char.isdigit():
38+
return True
39+
return False
40+
41+
print(contains_numbers('one is done'))
42+
print(contains_numbers('1 is done'))
43+
44+
def contains_numbers(input):
45+
return any(char.isdigit()
46+
for char in input
47+
)
48+
49+
print(contains_numbers('one is done'))
50+
print(contains_numbers('1 is done'))

stepic/get_books.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import requests as re
2+
for i in range(1, 3):
3+
img_data = re.get(f'https://www.litres.ru/pages/get_pdf_page/?file=98856895&page={i}&rt=w1900&ft=gif').content
4+
with open(f'page{i}.gif', 'wb') as handler:
5+
handler.write(img_data)

0 commit comments

Comments
 (0)