Question : W3Schools Var-Op-C 24

1. Variable Naming

2name = "Alex"

Why is this variable name invalid in Python?

2. Variable Naming Rule

user-name = "John"

What rule of variable naming is being violated here?

3. Case Sensitivity

age = 20
Age = 30

Are age and Age the same variable? Why or why not?

4. Reserved Words

class = "Science"

Why will this line cause an error?

5. Data Type Identification

x = 7.0

What is the data type of x, and how can you tell?

6. Type Conversion Issue

int("42.5")

Why does this cause an error, even though "42.5" looks like a number?

7. Input Always a String

value = input("Enter a number: ")

Why is the type of value a string even if the user types a number?

8. Input Conversion Error

n = int(input("Enter age: "))

What happens if the user enters "ten"? Why?

9. Division vs Floor Division

print(10 / 3)
print(10 // 3)

Why do these two lines produce different results?

10. Modulus Operator Usage

print(17 % 5)

What does the % operator compute here?

11. Exponent Operator

print(2 ** 3)

What does the ** operator do in this expression?

12. Comparison vs Assignment

a = 10
print(a == 10)

What is the difference between = and == in this example?

13. Indentation Requirement

if x > 10:
print("Greater")

Why will this code produce an indentation error?

14. Conditional Structure

if score > 90:
    print("A")
elif score > 80:
    print("B")
else:
    print("C")

What is the purpose of elif in this code?

15. Nested Conditionals

if num > 0:
    if num % 2 == 0:
        print("Even positive")

What does this nested conditional check?

16. Print Separator

print("Python", "Java", "C++", sep=" | ")

What does the sep parameter change in this output?

17. Print End Parameter

print("Hello", end="---")
print("World")

Why does “Hello—World” appear on one line?

18. String Concatenation

name = "Alice"
print("Hello " + name)

Why is + allowed here, and what would happen if you tried "Hello" + 5?

19. Multiline Comment Behavior

"""
This is a description.
It spans multiple lines.
"""

Why is this not technically a comment even though it behaves like one?

20. Multiline Print

print("Line1\nLine2\nLine3")

What role does \n play in producing the output?

Write what you are looking for, and press enter to begin your search!