-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex3.py
More file actions
60 lines (46 loc) · 1.98 KB
/
ex3.py
File metadata and controls
60 lines (46 loc) · 1.98 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
# Prints text specified in quotes on the screen
print "I will now count my chickens:"
# Calculates and prints the number of Hens
# 30 is divided by 6 and then the result is added to 25
print "Hens", 25 + 30 / 6
# Calculates and prints the number of Roosters
# Calculation of 100 - 25 * 3 % 4 is permormed as following:
# 1) 25 * 3 = 75
# 2) 75 % 4 = 3 (3 is the remainder of 75 divided by 4)
# 3) 100 - 3 = 97
print "Roosters", 100 - 25 * 3 % 4
# Prints text "Now I will count the eggs:"
print "Now I will count the eggs:"
# Calculates the number of eggs and prints this number on the screen
# Calculation of 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 is performed as following:
# 1) 4 % 2 = 0
# 2) 1 / 4 = 0.25 (but it will only use integer part, i.e. 0)
# 3) 3 + 2 + 1 - 5 + 0 - 0 + 6 = 1 + 6 = 7
print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
# Calculates the number of eggs and prints this number on the screen
# Uses floating numbers
print 3 + 2 + 1 - 5 + 4 % 2 - 1.0 / 4.0 + 6.0
# Prints text specified in quotes on the screen
print "Is it true that 3 + 2 < 5 - 7?"
# Calculates left and right part, compares and
# Prints result of comparison of 5 < -2
print 3 + 2 < 5 - 7
# Prints text specified in quotes on the screen
# Along with he result of calculation of 3 + 2, i.e. 5
print "What is 3 + 2?", 3 + 2
# Prints text specified in quotes on the screen
# Along with he result of calculation of 5 - 7, i.e. -2
print "What is 5 - 7?", 5 - 7
# Prints text specified in quotes on the screen
print "Oh, that's why it's False."
# Prints text specified in quotes on the screen
print "How about some more."
# Prints text specified in quotes on the screen
# Along with the result of comparison 5 > -2 , i.e. True
print "Is it greater?", 5 > -2
# Prints text specified in quotes on the screen
# Along with the result of comparison 5 >= -2 , i.e. True
print "Is it greater or equal?", 5 >= -2
# Prints text specified in quotes on the screen
# Along with the result of comparison 5 <= -2 , i.e. False
print "Is it less or equal?", 5 <= -2