Cyber Class 8 Python Programming Basics

Asked by Anurag Patra · ST. MICHAEL'S SCHOOL, DURGAPUR

What will be the output of the following Python code snippet?
x = 5
y = 2
result = x // y
print(result)

Answer as guest — Start Free Practice Test to earn Practice PointsHow to earn pointsAsk a question+3Answer a question+1Someone answers yours+1Your Q gets upvoted+1Pioneer bonus (first 5)+51 point = ₹1 discount on purchases, ask questions & climb the leaderboard!
Show answer and explanation

Answer: B. 2

The // operator in Python is the floor division (or integer division) operator. It divides the first number by the second and returns only the integer part of the quotient, discarding any decimal portion.
The expression 5 // 2 is calculated as 2.5, but the // operator truncates the result to the nearest whole integer, which is 2.

Answering after opening this box earns no Practice Points.

people 8 answered check_circle 38% got it right
70%