Exercises1
Python Practice Worksheet: Variables, Identifiers, and Operators
Part A: Variables & Identifiers
1. Create three variables: your name, age, and favorite color. Print them.
Answer: ________________________________________________
_________________________________________________________
_________________________________________________________
2. Identify which of the following are valid identifiers:
_value, 2nd_number, userName, for, my-name, amount$
Answer: ________________________________________________
_________________________________________________________
_________________________________________________________
Part B: Operators
1. Write a program to input two numbers and display:
- Sum
- Difference
- Product
- Quotient (float)
- Floor division
- Modulus
Answer: ________________________________________________
_________________________________________________________
_________________________________________________________
2. If x = 15 and y = 4, evaluate:
- x ** y
- (x > y) and (y < 10)
- (x % y) == 3
Answer: ________________________________________________
_________________________________________________________
_________________________________________________________
3. Use assignment operators to transform z = 20 into:
- z = z + 10
-z=z*2
-z=z-5
Answer: ________________________________________________
_________________________________________________________
_________________________________________________________
Part C: Challenge
Write a program that asks the user for two numbers and checks:
- If the first number is greater than the second.
- If both numbers are even.
- If the sum of the two numbers is divisible by 5.
Example Run:
Enter first number: 8
Enter second number: 12
First > Second? False
Both Even? True
Sum divisible by 5? False
Answer: ________________________________________________
_________________________________________________________
_________________________________________________________