7.2k views
0 votes
Write a program that displays the results of
1+2+3+4+5+6+7+8+9

1 Answer

3 votes

Let's go through Python


\tt s=0


\tt for\:i\:in\:range(1,10):


\quad\tt s+=i


\tt print(

  • The default value assigned to s is 0
  • Loop will call values from 1-9
  • s will store the sum of all values
  • In the end the sum is printed