Any2Quiz
Quizzes / CBSE / Class 8 / ICT / Programming Basics

Simple Python Programs Quiz - CBSE Class 8 ICT

Free practice quiz: Simple Python Programs (CBSE Class 8 ICT). 20 multiple-choice questions with answers and explanations. Play online, no sign-up needed.

This CBSE Class 8 ICT practice quiz has 20 multiple-choice questions on Simple Python Programs, and 20 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.

Start quiz: 20 questions, free

Sample questions

  1. What will be the output of the following code? print('Hello, World!')

    Show answer

    Answer: A. Hello, World!

    The print function in Python outputs the string exactly as it is provided. Thus, the output will be 'Hello, World!' with the comma and space included.

  2. What is the output of 5 // 2 in Python?

    Show answer

    Answer: A. 2

    The // operator in Python performs floor division, which discards the decimal part. So, 5 // 2 results in 2.

  3. What is the output of the following code? print(3 != 5)

    Show answer

    Answer: A. True

    The != operator checks if two values are not equal. Since 3 is not equal to 5, the output will be 'True'.

  4. What will the following code print when run? x = [1, 2, 3] print(len(x))

    Show answer

    Answer: B. 3

    The len() function returns the number of elements in the list x, which is 3.

  5. What will the following program output? def add(a, b): return a + b print(add(2, 3))

    Show answer

    Answer: A. 5

    The function add() takes two arguments, adds them, and returns the result. Therefore, add(2, 3) returns 5.

Take the full quiz

More questions in this quiz

Answers and explanations are in the full quiz.

  1. Which data type is used to define a number in Python?
  2. What will the following code print? x = 5 print(x * 2)
  3. What does the following code return? len('Python')
  4. Which of the following is a list in Python?
  5. What will the following code output? if 3 > 2: print('True') else: print('False')
  6. What is the purpose of the 'def' keyword in Python?
  7. What does the following code check? if x in [1, 2, 3]:
  8. What will the following code output? for i in range(3): print(i)
  9. What does the following code return? max([1, 2, 3])
  10. What is the result of the expression '3 + 2 * 2'?
  11. How can you create a comment in Python?
  12. What will the function call 'sorted([3, 1, 2])' return?
  13. What is the output of this code? for i in range(4): if i == 2: break print(i)
  14. Which of the following is a correct way to handle an exception in Python?
  15. What will be the output of the following code? def square(x): return x**2 print(square(4))

More quizzes

Browse all Programming Basics quizzes

More to play

Daily ChallengeA new quiz every day. Keep your streak.HangmanGuess the word, letter by letter.Story QuestLearn through short interactive stories.All quizzesCBSE, ICSE, competitive exams and more.