Computer Science, asked by Abhiahek1390, 10 months ago

For i in range (2,10,2): print (i, end=' ') give the output for the following snippet

Answers

Answered by thegamesoflifebykj
3

Answer:

2468

Explanation:

The loop has a start value of 2 so it will start from 2

With a Step value of 2, the loop will add 2 to its start value, until it reaches the stop value. the loop will print before the entered stop value(here, it is 10).

Attachments:
Answered by BrainlyYoda
3

The output of the códe snippet will be 2 4 6 8

Let's correct the question

Give the output for the following snippet

for i in range (2,10,2):

   print (i, end=' ')

Explanation

range() function is used to return a sequence of numbers in the order that we have set in the function.

Syntax of range() function

range(start, stop, step)

start is where we mention from which position the loop has to start. If not mentioned it starts from 0 by which we can say it is optional to mention it.

stop is where we want our loop to end. It is required to be mentioned.

step is used to increment so, that loop goes on. If not mentioned it has a default value of 1 by which we can say it is optional to mention it.

In the question, the for loop starts from 2 prints it, and then prints the value present in end which is a space, and then the loop skips two values and then prints 4 and again space and the loop goes on till 10

Extra Information

Python was created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.

Similar questions