Math Expressions Python Hw Collaborators_ipynb_2_
Part 2: Arithmetic Expressions
Calculate the following in Python using variables and arithmetic operators:
num1 ← 10
num2 ← 5
num3 ← num1 + num2 * 2
num4 ← (num1 + num2) * 2
num5 ← num3 / 3 + num4
- Display the values of
num3
,num4
, andnum5
.
Hint: Use
+
,-
,*
,/
, and parentheses to control order of operations.
Part 3: Step-by-Step Algorithm Practice
Write Python code for this algorithm without using loops or if statements:
Algorithm:
- Set
item
to7
- Create three variables:
num1 = 3
,num2 = 7
,num3 = 9
- Check each variable manually to see if it equals
item
(just write it as a sequence of assignments and displays) - Display
"Item found"
if a variable matchesitem
- At the end, display
"Item not found"
if none match
Hint: Since you haven’t learned
if
statements, just write a sequence that shows the comparisons step by step with comments.
Part 4: Mixed Expressions
Write a Python program that:
- Create three variables:
a = 8
,b = 4
,c = 10
- Calculate:
result1 = a + b * c
result2 = (a + b) * c
result3 = a + (b / c)
- Display all three results.
This will help you practice order of operations and arithmetic in Python.