Tutorials

https://vvcestudio.com.br/en/tutorial/python/
menu

What is Python?

Python is a scripted, interpreted, imperative, object-oriented, functional, dynamically typed, and strongly typed programming language.
It was launched by Guido van Rossum in 1991.

Python code example
x
x = 1
if x == 1:
#indentation is mandatory in Python.
print("x is 1.")

The language was designed with the philosophy of emphasizing the importance of programmer effort over computational effort.
Prioritizes code readability over speed or expressiveness.
It combines a concise and clear syntax with the powerful features of its standard library and third-party developed modules and frameworks.
Python is a high-level, multi-paradigm, general-purpose language, supports object-oriented, imperative, functional, and procedural paradigm.
It has dynamic typing and one of its main features is that it allows easy reading of the code and requires few lines of code compared to the same program in other languages.
Due to its characteristics, it is mainly used for text processing, scientific data and creating CGIs for dynamic web pages.
It was considered by the public the 3rd "most loved" language, according to a survey conducted by Stack Overflow in 2018, and is among the top 5 most popular languages, according to a survey conducted by RedMonk.

Using Python

Enter the Python command prompt
x
$ python
note: (Use "python" all lower case)
Exit the Python command prompt
x
exit()
# or
Ctrl + D
Declare variable
x
a = 3
Declare a list
x
a = [0,1,3]
Comment in Python
x
#this is a comment.
Create a for Loop
x
for item in range(10):
print(item)
Conditional (IF)
x
if a > 2:
print("A is greater than 2")
Note that indentation in Python is mandatory.
função no python
x
def nome_da_funcao(qtd_horas, valor_hora):
horas = float(qtd_horas)
taxa = float(valor_hora)
{"if horas <= 40:"}
salario=horas*taxa
else:
h_excd = horas - 40
salario = 40*taxa+(h_excd*(1.5*taxa))
return salario
Create Python code file
x
arquivo.py
Reading CSV file in Python
x
import CSV
with open("diretorio/arquivo.csv", "r") as entrada:
ler = csv.reader(entrada)
next(ler)
for linha in ler:
print(linha)
Run a Python 2 code file
x
$ python arquivo.py
To install Python3 on Ubuntu
x
$ python3 arquivo.py
To install Python3 on Ubuntu
x
$ sudo apt install python3-pip

Note: The name Python originated from the British comedy group Monty Python.

Some libraries
x
copy : numpy : scipy : math : multiprocessing : functools : time : sys : warnings : collections : datetime : itertools :