Postagens

Course Python For Life 4 – Variables

Imagem
As promised in the previous class, I present to you this lesson about variables. First we need to answer some questions. First, what’s a variable? The answer is: a variable is a space inside a memory, it save data and in programming languages, it also works for change the data inside it. Python is an high-level language, an high-level language is nearer of programmer, or human language like English for example. Python is simple! See below the variable declaration in languages like C, C++ or Java: This is the variable declaration structure, but in Python, we don’t need of this structure. So, declare the type isn’t required, but we need to initializer the variable. Below, see the variable declaration structure in Python: That’s enough, here we have the variable declaration in Python language. This structure is: variable_name = a_value, it can be a string too, or just a character. Test it in your interpreter, joyful! If you want to use other

Course Python For Life 3 – Input Command

Imagem
As was promised in the previous lesson, now we’ll see the input command in python language, it’s a smaller lesson, next lesson, we’ll see variable’s concepts in Python that’s different of others languages. First step: - I recommend that you use the output command. In python, input command requires a variable. There’s two ways to use this command, they’re: - with print. - without print. Note: In python, you don’t need to use ‘;’ in the end of a line, it works, but it isn’t required. With print: print(‘type any key...’) a = input() Test it yourself! See it in the editor: Run and see what happen. It required that the use type any thing by the keyboard. Below, see it being ran. But there’s other way to do this code, see below: a = input(‘Press any key...’) Test it yourself! Think about it, that’s the way to learn! The appearance is:  

Course Python For Life 2

Imagem
Hello folks! Now I present to you the lesson 2 of Python Course. In this lesson, we’ll see the first steps and began to programming. Below, see a small introduction. Python is an interpreted programming language, what’s it? See below a definition. Literally defined, a language which is not compiled directly into machine code. Most Scripting Languages are Interpreted Languages, since they are executed directly from their textfile format, and no intermediate format is stored on disk. Source: http://wiki.c2.com/?InterpretedLanguage Now, let’s go to began coding. I use the default interpreter that’s available when you install Python in your computer, but you can use other softwares. Open your IDE and create a new file. See the image below. This is the file created. Now, let’s go to some important things. The input and output commands in Python language. Note: I’m using python3.6, as whole course will be done. In

Course C Initial 17th - Loop FOR Part 2

Imagem
Now, I have others notes about loop for. This command can be used like while, but it structure is different because the loop for use ‘;’. Below, see the basic structure of For command.   Between ‘;’, you put a condition and so, the command will work like a loop while. So, it works with this: a variable; a condition; a increment or decrement. The command FOR is a good tool that will be used many times. But if you ask to me: What’s the difference between this command and the command do while or while? My answer is that the command for is universal, but do-while is a special case that in others languages, there’s not, python is an example. FOR works with conditions too, but it allow to us, work with a limited possibility. Look at this image: The image give us it explanation. But I have a note: the last value of a is 11, but 11 isn’t large than 10, that’s the reason of the code stop. Below, see it being ran. The comm

Course C Initial 16th - Loop For Part 1

Imagem
As promised in previous lesson, I present for you the Loop For. It has something different of Do while or while. It works with a condition and increments. It structure is here below. Another words, the commands will be ran up to the condition be False, generally when the increment or decrement happens and the condition become False, else it repeat. You can use more than a condition in your code if you desire, it depends of context. Below see an example of a loop for.   In this case, it doesn’t run the code because 20 is larger than 0, 20>0. If you change it for ‘a>=0’, so the condition is true up to a=-1. Make yourself! As we can see, we can create a variable outside for, but we can create it inside for too. In this case, the variable called a is known in all main function. Outside, a is unknown. Note: if you create a variable inside for, ‘for(type variable=0; condition; increment or decrement

Course C Initial 15th – While

Imagem
Now, I present to you the While command. It’s similar to Do While command in the lesson 14. below, we can see the structure. Below, see a example about the While loop use and the print of it running . Write it in your compiler. But if the condition be false, the code inside while will not ran. See the next example and test in your compiler. Well, it’s the enough to use the While loop. Please make the  Challenges 14.1 using the Loop While learned in this lesson. In the next lesson, we’ll see the Loop FOR. Well, that’s all folks See you later!

Course C Initial 14.1 – Do While Challenges

Imagem
As I said in the previous lesson, Access Here , I have to you 5 challenges to you practice your ability. 1- Make an algorithm that ask to user type numbers, the stop condition is when was typed the Number 0, say to user the stop condition. 2- Make an algorithm that aks to user many numbers, use the stop condition, when the user type 0, so print the sum result at display. 3- Make an algorithm that ask to user type a number and so use a do while to decrement this number up to 0. print them at display. 4- Make an algorithm that ask to user a number, you’ll multiplies by its predecessor up it be 0. Print all the process. 5- Make an algorithm that as to user letter, user the variable different of space character as condition. In the next lesson, we’ll see the Command While. Share it with your friends! Well, that’s all folks! See you later!