Computer Science, asked by mjmandelah07, 1 month ago

Given a range of first 10 numbers, Iterate from start number to the end number and print the sum of the current number and previous number: HINT : Python range() function

Answers

Answered by sumitrawat21
0

Answer:

n= int(input ("enter a number"))

s=0

for ele in range (1,11,1):

s+=ele

print (s)

Explanation:

hope it will help you

Answered by amanpanday2811
0

Answer:

Code

Explanation:

Loop- Python programming language provides the following types of loops to handle looping requirements. Python provides three ways for executing the loops. While all the ways provide similar basic functionality, they differ in their syntax and condition checking time. In python, a while loop is used to execute a block of statements repeatedly until a given condition is satisfied. And when the condition becomes false, the line immediately after the loop in the program is executed. All the statements indented by the same number of character spaces after a programming construct are considered to be part of a single block of code. Python uses indentation as its method of grouping statements while loop executes the block until a condition is satisfied. When the condition becomes false, the statement immediately after the loop is executed.

The else clause is only executed when your while condition becomes false. If you break out of the loop, or if an exception is raised, it won’t be executed.  It is suggested not to use this type of loops as it is a never ending infinite loop where the condition is always true and you have to forcefully terminate the compiler. For loops are used for sequential traversal. For example: traversing a list or string or array etc. In Python, there is no C style for loop, i.e., for (i=0; i<n; i++). There is “for in” loop which is similar to for each loop in other languages. Let us learn how to use for in loop for sequential traversals. We can also use the index of elements in the sequence to iterate. The key idea is to first calculate the length of the list and in iterate over the sequence within the range of this length.

Code-

n= int(input ("enter a number"))

s=0

for eel in range (1,11,1):

s+=eel

print (s)

For more refers to-

https://brainly.in/question/7697308?referrer=searchResults

https://brainly.in/question/25265399?referrer=searchResults

#SPJ2

Similar questions