Maths in Code
Briefing:
Are you any good at maths agent? Well, computers certainly are, and you can use programming to do all kinds of clever things. Let’s start you off with the basics, using programming to do some simple calculations.
Hint:
Make sure you read the challenge carefully and print the challenge results.
Doing the wrong calculation will obviously give you the wrong answer.
Code Solution:
The following code is the solution to this challenge. Please note that there may be alternative ways to complete this challenge.
# CHALLENGE 1: Multiply 80 by 512 and save it to a variable called ch1.
ch1 = 80*512
# CHALLENGE 2: Add 1024 to 768 and save it to a variable called ch2.
ch2 = 1024+768
# CHALLENGE 3: Do 40 minus 100 and save it to a variable called ch3.
ch3 = 40-100
# CHALLENGE 4: Divide 33 by 6 and save it to a variable called ch4.
ch4 = 33/6
# CHALLENGE 5: Do 2 to the power of 6 and save it to a variable called ch5.
ch5 = 2**6
# CHALLENGE 6: Save 0.33 to a variable called ch6_1, and save 5 to a
# variable called ch6_2. Multiply ch6_1 with ch6_2 and save
# the result to a variable called ch6.
ch6_1 = 0.33
ch6_2 = 5
ch6 = ch6_1 * ch6_2
# CHALLENGE 7: Print out the following variables in order:
# ch1, ch2, ch3, ch4, ch5, ch6
print(ch1)
print(ch2)
print(ch3)
print(ch4)
print(ch5)
print(ch6)