-
Notifications
You must be signed in to change notification settings - Fork 0
/
arithmetic.py
53 lines (46 loc) · 1.03 KB
/
arithmetic.py
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
# Addition (+)
print(2 + 3)
a = 2
b = 3
print('Addition', a + b)
# Subtraction (-)
print(3 - 2)
a = 3
b = 2
print('Subtraction', a - b)
# Multiplication (*)
print(2 * 3)
a = 2
b = 3
print('Multiplication', a * b)
# Division (/)
print(10 / 2)
a = 10
b = 2
print('Division', a / b)
# Area of a triangle
height = 6
base = 12
area = (height * base) / 2
print(area, 'meters squared')
# 1. Calculate the area of a triangle with a height of 10
# and a base of 5 (use python variables and print the result)
# answer = 25
height = 10
base = 5
area = (height * base) / 2
print(area, 'meters squared')
# 2. Calculate the area of a rectangle with a height of 10 and a width of 5
# (use python variables and print the result) area = height * width
# answer = 50
height = 10
width = 5
area = height * width
print(area, 'meters squared')
# 3. Calculate the perimeter of a rectangle with a height of 10 and
# a width of 5 (use python variables and print the result)
# perimeter = 2 * (height + width)
# answer =
height = 10
width = 5
perimeter = 2 * (height + width)