Sum of numbers: loops and conditionals

Here I am going to show you a program that sums a range of numbers provided by the user. For this problem I used a loop, and I learned to do so in python from here: http://www.python-course.eu/python3_loops.php 

I also had to use conditionals to make sure the first number the user entered was lower than the second, in order for the program to work correctly. Here is a flowchart explaining how conditionals work:

flowchart_if_else

Which I got from another page that helped me understand both conditionals and loops:

http://www.openbookproject.net/books/bpp4awd/ch04.html

At the end, my program looked like this:

sum

And ran like this:

sum-run

 

 

3 thoughts on “Sum of numbers: loops and conditionals

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s