Question : W3Schools Var-try-B 25

1. Variable Naming Rules — Question 1

Which of the following is a valid Python variable name?
a) 2name
b) student-name
c) _student1
d) class

2. Variable Naming Rules — Question 2

Why is my variable = 10 invalid in Python, and how should it be corrected?

3. Data Types — Question 3

What is the data type of the following value?
True

4. Data Types — Question 4

Write Python code that converts the number 45 into a string and stores it in a variable.

5. Input Statement — Question 5

Write a Python line that asks the user for their age and stores it as an integer.

6. Assignment & Comparison Operators — Question 6

What is the difference between = and == in Python?

7. Comparison Operators — Question 7

What will this expression return?
8 >= 12

8. Identity Operators — Question 8

What does the expression a is b check in Python?

9. Membership Operators — Question 9

Given items = [2, 4, 6], what does the expression 3 in items return?

10. Conditionals — Question 10

Write a simple if statement that prints “Even” if variable n is divisible by 2.

11. Conditionals — Question 11

What will the following code output?

if 5 > 10:
    print("A")
else:
    print("B")

12. Loops (Break) — Question 12

What does the break statement do inside a loop?

13. Loops (Continue) — Question 13

Explain what happens when a loop executes the continue statement.

14. Loops — Question 14

Write a loop that prints numbers 1 to 5 using a for loop.

15. Data Collections — Question 15

What is one key difference between a list and a tuple?

16. Data Collections — Question 16

Give an example of a Python set with three values.

17. Dictionaries — Question 17

Write a dictionary representing a student with keys: name, age, and grade.

18. Try/Except — Question 18

What does the code below prevent?

try:
    x = int("hello")
except:
    print("Error")

19. Exception Handling — Question 19

What is the purpose of the finally block in Python?

20. String Methods — Question 20

What will the following output?

print("hello world".title())
print("Python".upper())
print("DATA".lower())
Write what you are looking for, and press enter to begin your search!