Predict the output of the following code fragments:
x = 10 y = 5 for i in range(x-y * 2): print (" % ", i)
This code generates No Output.
The x-y * 2 in range(x-y * 2) is evaluated as below:
x-y * 2
range(x-y * 2)
x - y * 2⇒ 10 - 5 * 2⇒ 10 - 10 [∵ * has higher precedence than -]⇒ 0
Thus range(x-y * 2) is equivalent to range(0) which returns an empty sequence — [ ].
range(0)