ПРОГРАММИРОВАНИЕ
Задание № 2
Задание № 2
print('x', 'y', 'z', 'f', sep='\t')
for x in [False, True]:
for y in [False, True]:
for z in [False, True]:
#(¬x ∧ y ∧ z) ∨ (¬x ∧ ¬y ∧ z) ∨ (¬x ∧ ¬y ∧ ¬z).
f = ((not x) and y and z) or ((not x) and (not y) and z)
or ((not x) and (not y) and (not z))
print(x, y, z, f, sep='\t')
Задание № 4
b = 'ОВДПА'
code = ['00', '01', '10', '11', '100']
word ='ВОДОПАД'
temp = ""
for w in word:
ind = b.find(w)
temp += code[ind]
print(temp)
s3 = temp[-3:]
ans = str(oct(int(s3,2)))[2:]
for i in range(1,len(temp)//3 + 1):
s3 = temp[-3*(i+1):-3*i]
if s3 != '':
print(s3)
ans = str(oct(int(s3,2)))[2:] + ans
print(ans)
Задание №4
int(1001, 2)
9
bin(13)
0b1101
9
oct(13)
hex(13)
переводит из любой СС в 10-ю
1101
0o15
0xd
переводит из 10-й в 2-ю
15
переводит из 10-й в 8-ю
D
переводит из 10-й в 16-ю
Задание №5
for n in range(1,20):
n2 = bin(n)[2:]
print(n2)
sum = 0
for i in n2:
sum += int(i)
n2 += str(sum%2)
print(n2)
sum = 0
for i in n2:
sum += int(i)
n2 += str(sum%2)
print(n2)
r = int(n2, 2)
print(r)
Задание № 5
Задание №6
Задание № 6
#s = int(input())
for s in range(1000):
temp = s
s = s // 10
n = 1
while s
s = s + 5
n = n * 2
print(temp, n)
Задание №12
= 0: s = s[:ind] + '8' + s[ind + 3:] else: ind = s.find('888') s = s[:ind] + '2' + s[ind + 3:] print(s) " width="640"
Задание №12
s = '8'*68
while '222' in s or '888' in s:
ind = s.find('222')
if ind = 0:
s = s[:ind] + '8' + s[ind + 3:]
else:
ind = s.find('888')
s = s[:ind] + '2' + s[ind + 3:]
print(s)
Задание № 14
Сколько единиц содержится в двоичной записи значения выражения:
4 2020 + 2 2017 – 15?
a = 4**2020 + 2**2017 - 15
print(bin(a).count('1'))
Задание №17
kolvo = 0
max = 0
for i in range(1016, 7937 + 1):
if i%3 == 0 and i%7 !=0 and i%17 != 0 and i%19 != 0 and i%27 != 0:
kolvo += 1
max = i
print(kolvo, max)
Задание №24. Конечные автоматы
Задание №24. Конечные автоматы