Python Test 1

    Question 1Python Variable Assignment

    Which of the following is a valid variable declaration in Python?

    Question 2Python Arithmetic Operator

    What will be the output of the following code?

    x = 7 // 2 print(x)

    Question 3Python Integer Casting

    What will be the output of the following code?

    x = int(7.8) print(x)

    Question 4Python While Loop Execution

    What will be the output of the following code?

    x = 0 while x < 3: print(x, end=" ") x += 1

    Question 5Python If-Else Condition

    What will be the output of this code?

    x = 10 if x > 5: print("Big") else: print("Small")

    Question 6Python Functions - Default Arguments

    What will be the output of the following code?

    def greet(name="Guest"): return f"Hello, {name}" print(greet())

    Question 7Python Lists - Creation

    Which of the following is a valid way to create a list?

    Question 8Python Dictionaries - Creation

    Which of the following is a valid way to create a dictionary?

    Question 9Python Strings - Creation

    Which of the following is a valid way to create a string?

    Question 10Python OOPs - Class Creation

    Which of the following correctly defines a class in Python?

    Question 11Python Data Type Identification

    What will be the data type of x after execution?

    x = 3.14

    Question 12Python Exponentiation Operator

    Which of the following is the correct operator for exponentiation (power) in Python?

    Question 13Python Float Casting

    What will be the output of the following code?

    x = float(3) print(x)

    Question 14Python For Loop with Range

    What will this code output?

    for i in range(2, 5): print(i, end=" ")

    Question 15Python If-Elif-Else Ladder

    What is the output?

    x = 0 if x > 0: print("Positive") elif x == 0: print("Zero") else: print("Negative")

    Question 16Python Functions - Built-in len()

    What does len("Python") return?

    Question 17Python Tuples - Immutability

    What happens when you execute the following?

    t = (1, 2, 3) t[0] = 10

    Question 18Python Dictionaries - Accessing Values

    What will be the output?

    d = {"x": 10, "y": 20} print(d["x"])

    Question 19Python Strings - Indexing

    What will this code print?

    s = "Python" print(s[0])

    Question 20Python OOPs - Object Instantiation

    What is the correct way to create an object of a class Person?