Actually, in Python, both multiplication (*) and floor division (//) have the same precedence level, and they are evaluated from left to right.
So, in the given code print(1 // 2 * 3):
1 // 2 is evaluated first, resulting in 0 because 1 divided by 2 is 0.5 and the floor division of 0.5 is 0.
Then, 0 * 3 is evaluated, which is 0.
Therefore, the expected output is indeed 0.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
hovnival
1 month, 1 week ago