-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnumbers.qs
More file actions
49 lines (38 loc) · 843 Bytes
/
Copy pathnumbers.qs
File metadata and controls
49 lines (38 loc) · 843 Bytes
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
# Numbers and operators
a = 10
b = 3
print("a + b =", a + b)
print("a - b =", a - b)
print("a * b =", a * b)
print("a / b =", a / b)
print("a % b =", a % b)
# Parentheses make the order clear.
answer = (2 + 3) * 4
print("answer:", answer)
# Negative numbers.
x = -5
print("negative:", x)
print("negate:", -x)
# Comparison operators.
print("10 == 10:", 10 == 10)
print("10 != 5:", 10 != 5)
print("3 < 5:", 3 < 5)
print("3 > 5:", 3 > 5)
print("3 <= 3:", 3 <= 3)
print("3 >= 5:", 3 >= 5)
# Chained comparisons.
y = 3
print("0 < 3 < 5:", 0 < y < 5)
print("0 < 3 < 2:", 0 < y < 2)
# Short assignment operators change the old value.
score = 1
score += 4
print("score += 4:", score)
score -= 2
print("score -= 2:", score)
score *= 3
print("score *= 3:", score)
score /= 3
print("score /= 3:", score)
score %= 2
print("score %= 2:", score)