QuizSpace

Python week 5 important questions

Week 5 of Programming in Python: Iterations & ranges (contd.). Extra important questions based on the recent, changing patterns of the exams, from basic to advanced. Practise them in learning mode: each question has a worked solution.

Question 1

One correct option

What is printed by the following program?

for i in range(2, 0, -1):
print(i * "ab")
  1. A

    abab

  2. B

    abab
    ab

  3. C

    (nothing is printed)

  4. D

    ababab
    abab

Question 2

One correct option

What will be the output of the code below?

for i in range(4):
print("#" * (i + 1))
  1. A

    ##
    ###
    ####
    #####

  2. B

    # 1
    # 2
    # 3
    # 4

  3. C

    #
    ##
    ###
    ####

  4. D


    #
    ##
    ###

Question 3

One correct option

Run the program in your head. What is the output?

for i in range(5):
for j in range(2):
print(i + j, end=" ")
print()
  1. A

    0 1
    1 2
    2 3
    3 4
    4 5

  2. B

    0 0
    0 1
    0 2
    0 3
    0 4

  3. C

    0 1 1 2 2 3 3 4 4 5

  4. D

    0 1
    1 2
    2 3
    3 4
    4 5
    5 6

More questions in this week

Authorise with Google to see every question with its answer and explanation and practise it in learning mode.

IMPPractise OPPE 1 PYQs:PythonSystem CommandsJava