Question : W3Schools Var-try-A 25

1. Variable Naming Rules

  1. Which of the following is a valid Python variable name?
    a) 2name b) student_name c) first-name

  2. Why is my variable = 10 invalid in Python?

  3. What is the difference between Age and age as variable names?

2. Data Types

  1. Identify the data type of: {"a", "b", "c"}

  2. What will type(3.0) return?

  3. Convert the number 7 into a string.

3. Input Statements

  1. Write a Python statement to take a user’s age as an integer input.

  2. What data type is returned by input() by default?

4. Operators

  1. Which operator checks identity between two variables?

  2. What is the output of: 5 == "5" and why?

  3. What does the operator in do in Python?

5. Conditionals

  1. Write a simple if-statement that prints "Adult" if age ≥ 18.

  2. What is the purpose of the else block?

6. Loops (break, continue)

  1. What is the difference between break and continue?

  2. What does the following loop print?

for i in range(5):
    if i == 2:
        continue
    print(i)

7. Collections: list, tuple, set, dict

  1. What is the main difference between a list and a tuple?

  2. Which collection does not allow duplicate values?

  3. How do you access the value associated with key "age" in:

student = {"name": "Sam", "age": 10}

8. Try / Except / Finally

  1. What does the finally block do in a try/except structure?

  2. Write a small snippet that catches a ZeroDivisionError.

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