Activity for Python Lesson #2

Hello everyone! This week we covered operators and if statements in Python. Here’s a simple activity to see if you actually learned anything!

Create three variables: num_1, num_2, and num_3 and give them a number value (an integer or a float).

Find the average (mean value) of the numbers in the three variables and print that.

Then, check to see whether the average is postive, negative, or zero, and accordingly print one of the following strings: “The average is positive”, “The average is negative”, or “The average is zero”.

That’s all!

Trials

Try testing your code with your initial variables as the following values.

This should print “3.5” and “The average is positive”:

num_1 = -5
num_2 = 8
num_3 = 7.5
# YOUR CODE HERE

This should print “0.0” and “The average is zero”:

num_1 = 7
num_2 = -4.0
num_3 = -3
# YOUR CODE HERE

This should print “-1.0” and “The average is negative”:

num_1 = -7
num_2 = 1
num_3 = 3
# YOUR CODE HERE

The answers will be posted next Monday. If you have any questions, please contact us, either via email or Discord.

Good luck!