Variables, Types & Operators · Question 2 · Easy

Riya shares 17 chocolates equally among 5 friends and keeps the leftovers. What does this code print?

print(17 // 5, 17 % 5)
  1. 3.4 2
  2. 2 3
  3. 3 2
  4. 3 2.0
Answer and explanation

Answer: C. 3 2

Explanation: 17 // 5 is floor division, giving 3 whole chocolates each. 17 % 5 is the remainder, 17 - 15 = 2. Both results are integers.

Previous: The name x is first bound to a number and then to text. What does this snippet… · Next: A roll number typed as text is converted before adding. What is printed?

Practise variables, types & operators

Try a fresh set of variables, types & operators questions with an explanation after every answer, free and without signing up: Variables, Types & Operators practice. Or sit a full placement mock test.

More variables, types & operators questions

More python practice

Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge