-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhometask2.py
More file actions
22 lines (22 loc) · 784 Bytes
/
hometask2.py
File metadata and controls
22 lines (22 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 1
philosophy = "Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. " \
"Complex is better than complicated. Flat is better than nested. Sparse is better than dense.Readability counts."
print("Count of word 'better' - ", philosophy.count('better'))
print("Count of word 'never' - ", philosophy.count('never'))
print("Count of word 'is' - ", philosophy.count('is'))
print(philosophy.upper())
print(philosophy.replace('i', '&'))
# 2
n = str(4832)
product = int(n[0])*int(n[1])*int(n[2])*int(n[3])
print("Product of multiplication is ", product)
print("Reverse writing of number is ", int(n[::-1]))
print("Sorted number is ", int(''.join(sorted(n))))
# 3
a = 5
b = 3
a = a + b
b = a - b
a = a - b
print("a = ",a)
print("b = ",b)