Getting Started with Python · Class 11 · CBSE · Science Computer Science
What is the output of the following Python code? x = 7 y = 2 print(x // y, x % y)
Practice question from Getting Started with Python (Class 11 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.
medium · MCQ · Q-7D64CD
What is the output of the following Python code? x = 7 y = 2 print(x // y, x % y)
- A.3 1Correct answer
- B.3.5 1
- C.4 0
- D.3 0
Solution
The // operator performs floor division, so 7 // 2 gives 3. The % operator gives the remainder, so 7 % 2 gives 1.
More from Getting Started with Python
- In Python's interactive mode, what does the prompt >>> generally indicate?
- What will be printed when the following Python code is executed and the user enters 12 on the first line and 3 on the second line? a = inpu…
- Explain the difference between a syntax error and a runtime error in Python, and give one example of each.
- Which of the following is a valid Python identifier?
Practise more Computer Science
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed