Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":5795,"date":"2015-02-19T18:11:13","date_gmt":"2015-02-20T00:11:13","guid":{"rendered":"http:\/\/prosecutor.withknown.com\/2015\/sum-of-numbers-for-loops"},"modified":"2015-02-19T18:11:13","modified_gmt":"2015-02-20T00:11:13","slug":"sum-of-numbers-for-loops","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2015\/2015\/sum-of-numbers-for-loops\/","title":{"rendered":"Sum of Numbers (‘for’ loops)"},"content":{"rendered":"
\n

The next program ask the user for two numbers, the first is the lower limit of a range of numbers, and the second is the maximum. The program then takes all the numbers in the given range and makes the sum of all the numbers in the given interval, including the limits.<\/p>\n

The source code is the given:<\/p>\n

#Sum<\/a> of Numbers<\/p>\n

 <\/p>\n

n1=int(input(“Enter the lower limit of the range “))<\/p>\n

n2=int(input(“Enter the higher limit of the range “))<\/p>\n

 <\/p>\n

if(n2<n1):<\/p>\n

    print(“The lower limit must be a lower number than the second”)<\/p>\n

sumnum=0<\/p>\n

 <\/p>\n

for num in range(n1,n2+1):<\/p>\n

    sumnum=sumnum+num<\/p>\n

 <\/p>\n

print(“The sum is “,sumnum)<\/p>\n

The first thing the program does is validate that the user don’t crash the program, it simply applies a conditional that tells the user that the inputs are incorrect, thus the program wont do nothing.<\/p>\n

In the program we can see a for <\/strong>loop. The for <\/strong>loop is used when we know how many times we are going to be in a loop, or when we need a given variable that will be incremented in every run that we make of the loop. This is used very often to navigate inside arrays and other arranges. <\/p>\n

The for loop in Python is used in conjuction with the range <\/strong>command, wich gives us an array of integers when we type the lower and the upper limit; but beware, the upper limit is not inclusive, thus you must use a +1.<\/p>\n

Then the program uses this loop and navigates the array adding to the accumulative of the two numbers before the next number in the array, thus making the sum of all the numbers in the array. <\/p>\n

At the end the program prints the accumulative sum of all the integers in the array. <\/p>\n

This is for my #WSQ07<\/a> #Mastery20<\/a> #Mastery29<\/a> of my #TC1014<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

The next program ask the user for two numbers, the first is the lower limit of a range of numbers, and the second is the maximum. The program then takes all the numbers in the given range and makes the sum of all the numbers in the given inter… Continue reading →<\/span><\/a><\/p>\n","protected":false},"author":167,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,25],"tags":[171,227,301,45,169],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/5795"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/users\/167"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/comments?post=5795"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/5795\/revisions"}],"predecessor-version":[{"id":7343,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/5795\/revisions\/7343"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/media?parent=5795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/categories?post=5795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/tags?post=5795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}