-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path55.py
59 lines (54 loc) · 1.81 KB
/
55.py
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
56
57
58
59
# import simplecrypt
#
# with open('C:\Python\maya\encrypted.bin', 'rb') as fo:
# ciphertext = fo.read()
# with open('C:\Python\maya\passwords.txt') as fin:
# for line in fin:
# line = line.replace('\n', '')
# try:
# dec = simplecrypt.decrypt(line, ciphertext)
# except simplecrypt.DecryptionException:
# pass
# else:
# print(line, dec)
# with open('C:\Python\maya\crypted.bin', 'wb') as fo:
# fo.write(dec)
# # print("decrypted text: %s" % dec)
# #---------------------------------
# import requests
# from simplecrypt import decrypt, DecryptionException
#
# code = requests.get('https://stepic.org/media/attachments/lesson/24466/encrypted.bin').content
# passes = requests.get('https://stepic.org/media/attachments/lesson/24466/passwords.txt').content
#
# for p in passes.split():
# try:
# s = decrypt(p, code)
# except DecryptionException:
# pass
# else:
# print(p, s)
#====================================================
import itertools
# itertools.takewhile(func, iterable) #возвращает элементы до тех пор, пока func возвращает истину.
def primes():
i = 2
while True:
for j in range(2,i):
if i % j == 0:
break
else:
yield i
i+=1
print(list(itertools.takewhile(lambda x: x < 5, [1, 4, 6, 4, 1])))
print(list(itertools.takewhile(lambda x : x <= 31, primes())))
# n = input("n=")
# lst = []
# for i in xrange(2, n+1):
# for j in xrange(2, i):
# if i % j == 0:
# # если делитель найден, число не простое.
# break
# else:
# lst.append(i)
# print lst