From 40f7216759c962dc6ac6ed795e71664d2e702fe0 Mon Sep 17 00:00:00 2001 From: Adalberto Caldeira Brant Filho Date: Mon, 30 Oct 2017 09:01:45 -0200 Subject: [PATCH] Create sum_total_numbers_0_to_10.py Sum total value of integers numbers from 0 to 10 in python. --- SimpleAddition/sum_total_numbers_0_to_10.py | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 SimpleAddition/sum_total_numbers_0_to_10.py diff --git a/SimpleAddition/sum_total_numbers_0_to_10.py b/SimpleAddition/sum_total_numbers_0_to_10.py new file mode 100644 index 0000000..2242818 --- /dev/null +++ b/SimpleAddition/sum_total_numbers_0_to_10.py @@ -0,0 +1,24 @@ +### Sum all integers numbers between 0 to 10 included + +# Create 2 variables, one to keep the result(sum) and another to count(i) + + +sum=0 ### sum is the variable where the value of 0+1+2+3+4+5+6+7+8+9+10 will be added . +i=0 ### i is the counter, so we could add the value to the sum. + +# Create a loop using while(condition): + # calculation + +while (i<=10): + ### sum receive the anterior value of sum plus the value of i + + sum=sum+i + + ### In this line we increase the value of i , another form to write is i=i+1 + + i+=1 + +# print the result in the screen + +print (sum) +