Skip to content

Latest commit

 

History

History
86 lines (66 loc) · 1.7 KB

File metadata and controls

86 lines (66 loc) · 1.7 KB
  1. What will be the output of the following code?

    • A) a, b, c
    • B) a, b, c, d
    • C) c, d, e ✓
    • D) c, d, e, f
  2. Which of the following is a valid way to declare a dictionary in Python?

    • A) {1: "one", 2: "two", 3: "three"} ✓
    • B) [1: "one", 2: "two", 3: "three"]
    • C) (1: "one", 2: "two", 3: "three")
    • D) <1: "one", 2: "two", 3: "three>
  3. Which of the following method is correct to add an element at a specific position?

    • A) insert() ✓
    • B) add()
    • C) append()
    • D) index()
  4. What is the correct syntax to add an item to the end of a list in Python?

    • A) list.add(item)
    • B) list.append(item) ✓
    • C) list.insert(item)
    • D) list.extend(item)
  5. Which of the following is not a valid data type in Python?

    • A) integer
    • B) string
    • C) float
    • D) character ✓
  6. What is the output of the following code?

   for i in range(1, 21):

    if i % 3 == 0 and i % 5 == 0:

        print("FizzBuzz")

    elif i % 3 == 0:

        print("Fizz")

    elif i % 5 == 0:

        print("Buzz")

    else:

        print(i)
  • A) Prints numbers from 1 to 20
  • B) Prints Fizz for multiples of 3 and Buzz for multiples of 5 ✓
  • C) Prints FizzBuzz for multiples of 3 and 5
  • D) None of the above
  1. What is the output of the following code?
a = 5

b = 2

print(a // b)
  • A) 2 ✓
  • B) 2.5
  • C) 3
  • D) 2.0
  1. What is the output of the following code?

    • A) "hello"
    • B) "olleh" ✓
    • C) "hlo"
    • D) "leh"
  2. What is the output of the following code?

    • A) 2
    • B) 5
    • C) 0 ✓
    • D) 1
  3. What is the output of the following code?

  • A) "pyt"
  • B) "yth" ✓
  • C) "tho"
  • D) "hon"