What is the output of the following range () function for num in range (2,-5,-1): Print (num,end = ",")
Answers
Answer:
Since momentum is the same for the lighter as well as the heavier body then we can say that the lighter body moves with a greater velocity. We know that momentum is the product of velocity and mass of a particle.
Explanation:
Concept:
The range() function returns a number series that starts at 0 (by default) and advances by 1 (by default) until it reaches a specified value.
Syntax:
range(start, stop, step)
Given:
for num in range(2,-5,-1):
print(num, end=", ")
Find:
Find the output of the given code.
Solution:
start - It is an optional parameter. It is an integer number specifying at which position to start. The default value of start is 0.
stop - It is a required parameter. It is an integer number specifying at which position to stop (stop is not included).
step - It is an optional parameter. It is an integer number specifying the incrementation. The default value of step is 1.
In given program:
start = 2
stop = -5
step = -1
∴ Output will be .