Ex1 Find the aggregate state of water by temperature def aggregate_sta

 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
# Ex1: Find the aggregate state of water by temperature
def aggregate_state(temp):
if temp < 0:
print('ice')
elif temp == 0:
print('difficult')
elif 1 < temp < 99:
print('water')
else:
print('gas')
print("Exercise 1:")
print(aggregate_state(12))
print(aggregate_state(2222))
# Ex2: Sort numbers
arr1 = [3, 12, 7]
arr1.sort()
print("Exercise 2:")
print(arr1)
# Ex3: Check if one of numbers is multiplier for the rest
def is_multiplier(n1, n2, n3):
min_value = min(n1, n2, n3)
return n1 % min_value == 0 and n2 % min_value == 0 and n3 % min_value == 0
n21 = 12
n22 = 4
n23 = 47
print("Exercise 3:")
print('Is multiplier: ' + str(is_multiplier(n21, n22, n23)))
# Ex4: Find length of the string
string1 = 'aabbcc'
print("Exercise 4:")
print(len(string1))
# Ex5: Replace I with 1 and O with 0
string2 = "THERE IS SOME POINT IN THIS TASK"
print("Exercise 5:")
print (string2.replace("I", "1")).replace("O", "0")
# Ex 6: Format string with name and age
name = 'Vasya'
age = 23
print("Exercise 6:")
print ('Dear %s we are happy to congratulate you with %d birthday' % (name, age))