Basic concepts
Some basic concepts are very important for learning programming. They are variables, mathematical operators, logical operators and loops.
We will study these concepts through a practical approach using the Python language.
Python is a general purpose programming language that has become very popular for being easy to learn and use, having several frameworks and libraries , being versatile, efficient, fast, flexible and having good support for machine learning.
Our goal is not to deepen learning about Python. For more details on Python, visit the official language
But we will use language Python to learning the basic concepts of Programming Logical
Then, lets go
To begin is need install the Python. We will go use the 3.x version.
You can use vim, notepad, notepad++ or any other text editor. To develop the code examples for this article
Variables
We can describe a variable as a part of memory where we store data to process or display through the program
Ex: If we want a program to add two values and display the result to the user.
In Python we can do the following example:
program 01
This program has four lines. In lines one and two were stored the values 10 and 5 in the variables number1 and number2 respectively. In line three, the sum between variables number1 and number2 was stored in the result variable. In line four, the result will be display to user.
OBS: To execute the program open the terminal and run the command python program01.py
program 02
In this program We want to store the username in the name variable and display the message "Your name is " _typed_name
This program has three lines. On the first line, the message "What's your name" will be displayed to the user via the print command. On the second line, the name entered by the user will be stored inside the variable name. On the thirth line the message displayed to the user will be 'Your name is ' concatenate with the name sotered inside the vairiable name.
To execute the program open the terminal and run the command python program02.py
Comentários
Postar um comentário