Computer Science, asked by deepalisoni2222, 9 months ago

Find output from following code
s=0
for I in range(10,2,-2):
s+=I
print ("sum=",s)

Answers

Answered by saketbanwaripur
5

Explanation:

used when a user needs to perform an action for a specific number of times. range() in Python(3.x) is just a renamed version of a function called xrange in Python(2.x). The range() function is used to generate a sequence of numbers.

range() is commonly used in for looping hence, knowledge of same is key aspect when dealing with any kind of Python code. Most common use of range() function in Python is to iterate sequence type (List, string etc.. ) with for and while loop.

Python range() Basics :

In simple terms, range() allows user to generate a series of numbers within a given range. Depending on how many arguments user is passing to the function, user can decide where that series of numbers will begin and end as well as how big the difference will be between one number and the next.range() takes mainly three arguments.

Similar questions