Python Worksheet for Beginners
Part A – Write the Output
1.
x = 5
print(x)
2.
name = "Lara"
print(name)
3.
a = 10
b = 2
print(a + b)
4.
price = 50
discount = 20
print(price - discount)
5.
x = 5
y = 3
print(x > y)
Part B – Boolean Operators (Write True or False)
5 > 2 and 3 > 1 → ______
4 == 4 or 5 == 10 → ______
not(3 < 1) → ______
10 > 50 and 2 == 2 → ______
7 != 7 or 1 < 2 → ______
Part C – Find the Error (if any)
my name = "Ravi"
5 = x
print("Hello)`
total = 10 +
2print("Hi")
Part D – Write the Code
1. Ask the user to enter their name and print: Hello
2. Ask the user to enter two numbers and print the sum.
3. Write code to check if a number is equal to 10.
4. Write code to check if a number is not equal to 7.
5. Create two variables x = 8 and y = 3 and print if x is greater than y and y is less than x.