Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/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/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/feed-rss2.php on line 8
‘#masteries1&5’ Articles at TC101 Fall 2015 https://kenscourses.com/tc101fall2015 Introduction to Programming Python and C++ Fri, 18 Sep 2015 18:22:55 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Use of the conditionals “If” and “Elif” https://kenscourses.com/tc101fall2015/2015/use-of-the-conditionals-if-and-elif/ Fri, 18 Sep 2015 18:22:55 +0000 http://saldabal.wordpress.com/?p=37 Continue Reading →]]> There is something in math called Conditional expressions. They are expressión that can only be answered with YES or NOT. So the statements needed to declare one expression of this kind must be also special, they are called conditionals.

So we must use this statement to value if our expression is True or False. For that purpose we’ll use the special word “If”

“If” in python means the same as it does in the english language. So after typing “If” you must state the expression you want to evaluate, either to be TRUE, or FALSE.

An example of this will be.

x = 5

if ( x == 5):

print(‘True’)

It is very important that at the end of our statement we put a colon (:) because this means that the block of code we write next to it (actually under it and with a space tab) will be part of what will be executed in case that our conditional turns out to be TRUE.

In the previous example, the code i wrote translated to english will literally mean:

set the value of x to 5

if x is equal to 5, print ‘True’

But what if our expression is valuated at False. That would mean that our block of code we wrote under the expression wont be executed. In this case we have two options, we can just let it like that or we can arrange a second conditional to say what we want the computer to execute in case that it (the second conditional) turns out TRUE. For this purpose we can use the special word: ELIF, this is kind of a combination of Else If.

So let’s see an example.

Correct use of "if" and "elif"
Correct use of “if” and “elif”

In this piece of code we can see how at first instance, the value of x is equal to 5. Then we tried to evaluate x, so we´re saying that if x is equal to 6, print in the screen ‘If’ but because we set the value at 5 this turns out to be false, so it wont print ‘If’

Then we set an Elif, which is kind of “if the last ‘If’ statement doesn´t work, evaluate this to see if it’s true so you can run it.”

The Elif says that if the value of x is equal to 5, print ‘Elif’.

At the moment you run the program, it prints ‘Elif’ because the conditions of Elif is True.

Thats how If and Elif works, you just have make sure you know where and when you want to evaluate

]]>
https://creativecommons.org/licenses/by/4.0/
c++ linux https://kenscourses.com/tc101fall2015/2015/c-linux/ Sat, 12 Sep 2015 21:18:03 +0000 http://progradianagdv.wordpress.com/?p=23 In this video you can see how to create a program in c++ and run it in the terminal from linux

]]>
https://creativecommons.org/licenses/by/4.0/
c++ linux https://kenscourses.com/tc101fall2015/2015/c-linux-2/ Sat, 12 Sep 2015 21:18:03 +0000 https://progradianagdv.wordpress.com/?p=23 In this video you can see how to create a program in c++ and run it in the terminal from linux

]]>
https://creativecommons.org/licenses/by/4.0/