0% found this document useful (0 votes)
24 views2 pages

Python Variables and Operators Exercises

This document is a Python practice worksheet focusing on variables, identifiers, and operators. It includes exercises for creating variables, identifying valid identifiers, performing arithmetic operations, evaluating expressions, using assignment operators, and a challenge program to compare two numbers. The worksheet is structured in parts with specific tasks and expected outputs.

Uploaded by

Sky Vilasco
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Python Variables and Operators Exercises

This document is a Python practice worksheet focusing on variables, identifiers, and operators. It includes exercises for creating variables, identifying valid identifiers, performing arithmetic operations, evaluating expressions, using assignment operators, and a challenge program to compare two numbers. The worksheet is structured in parts with specific tasks and expected outputs.

Uploaded by

Sky Vilasco
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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: ________________________________________________

_________________________________________________________

_________________________________________________________

You might also like