-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson2.py
More file actions
66 lines (46 loc) · 1.29 KB
/
Copy pathlesson2.py
File metadata and controls
66 lines (46 loc) · 1.29 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
56
57
58
59
60
61
62
63
64
65
66
#Task - 1
import this
import codecs
zen_of_python = codecs.encode(this.s, 'rot13')
print('''
''')
count_better = zen_of_python.count('better')
print ("number of occurrences 'better' - {}".format(count_better))
count_never = zen_of_python.count('never')
print ("number of occurrences 'never' - {}".format(count_never))
count_is = zen_of_python.count('is')
print ("number of occurrences 'is' - {}".format(count_is))
zen_upper = zen_of_python.upper()
print('''
''')
print ("zen upper:")
print (zen_upper)
zen_replace = zen_of_python.replace('i','&')
print('''
''')
print ("zen replace 'i' -> '&':")
print (zen_replace)
#Task - 2
a = input("4-хзначне число: ")
dobutok = int(a[0])*int(a[1])*int(a[2])*int(a[3])
print ("добуток чисел - {}".format(dobutok))
revers = a[3] + a[2] + a[1] + a[0]
print ("реверсний порядок - {}".format(revers))
i = 4
sort = [a[0], a[1], a[2], a[3]]
while i > 1:
for j in range(i-1):
if sort[j] > sort[j+1]:
k = sort[j]
sort[j] = sort[j+1]
sort[j+1] = k
i -= 1
print ("відсортовані цифри - {}".format(sort))
#Task - 3
x = int(input("x: "))
y = int(input("y: "))
x = x + y
y = x - y
x = x - y
print ("x = {}".format(x))
print ("y = {}".format(y))