Tutorial de Python para Iniciantes
Tutorial de Python para Iniciantes
Tabela de conteúdos
Introdução 0
The dataset of U.S. baby names 1
Instalando o Python 2
First steps on the IPython Shell 3
Using Python as a calculator 3.1
Storing numbers 3.2
Storing text 3.3
Converting numbers to text and back 3.4
Writing Python programs 4
Writing to the screen 4.1
Reading from the keyboard 4.2
Repeating instructions 4.3
Storing lists of items 4.4
Making decisions 4.5
Reading and writing files 5
Reading a text file 5.1
Writing a text file 5.2
File parsing 5.3
Working with directories 5.4
Builtin functions 6
Shortcuts 6.1
String functions 6.2
Introspection 6.3
Leftovers 7
Data types in Python 7.1
Dictionaries 7.2
Tuples 7.3
while 7.4
Tables 7.5
Structuring bigger programs 8
2
Tutorial de Conceitos Básicos do Python 3
Functions 8.1
Modules 8.2
Packages 8.3
Additional Exercises 9
Review Questions 10
Background information on Python 3 11
Recommended books and websites 12
Acknowledgements 13
3
Tutorial de Conceitos Básicos do Python 3
Introdução
Este tutorial funciona melhor se você seguir os capítulos e exercícios passo a passo.
Para um tutorial para não-iniciantes, recomendo os seguintes livros gratuitos online (em
inglês):
Introdução 4
Tutorial de Conceitos Básicos do Python 3
How to think like a Computer Scientist - a very systematic, scientific tutorial by Allen B.
Downey
Dive into Python 3 - explains one sophisticated program per chapter - by Mark Pilgrim
Introdução 5
Tutorial de Conceitos Básicos do Python 3
The authorities of the United States have recorded the first names of all people born as U.S.
citizens since 1880. The dataset is publicly available on
[Link] . However for the protection of privacy only
names used at least 5 times appear in the data.
Instalando o Python
O primeiro passo na programação é ter o Python instalado no computador. Basicamente
você precisará de duas coisas:
o próprio Python
um editor de textos
No Ubuntu Linux
Por padrão, o Python já vem pré-instalado. Porém, neste tutorial iremos utilizar o Python3
sempre que possível. Você poderá instalá-lo a partir da linha de comando (Ctrl+Alt+T) com:
ipython3
No caso do editor de textos seria legal iniciarmos com o gedit. Por favor, certifique-se de
mudar tabulações para espaços em Preferências -> Editor -> marque 'Inserir espaços em
vez de tabulações'. Também é recomendável, nesta mesma tela, reduzir Largura das
tabulações: para 4.
No Windows
Uma maneira conveniente de instalar o Python, um editor e muitos pacotes adicionais em
uma única etapa seria o WinPython.
Instalando o Python 7
Tutorial de Conceitos Básicos do Python 3
Outros editores
Idle - o editor padrão do Python
Sublime Text - um editor de textos muito poderoso para todos os sistemas
operacionais
Notepad++ - um poderoso editor de textos para o Windows.
PyCharm - um ambiente de desenvolvimento profissional para Python, com
capacidade para lidar com grandes projetos. Você não precisará da maioria das
funcionalidades por um longo tempo, mas é um editor muito bem feito.
vim - um editor de textos baseado em console para sistemas Unix. A ferramenta
preferida de muitos administradores de sistema.
Perguntas
Pergunta 1
Quais editores de texto estão instalados em seu sistema?
Pergunta 2
Qual a versão do Python que você está rodando?
Instalando o Python 8
Tutorial de Conceitos Básicos do Python 3
In the first part of the tutorial, you will use the IPython shell to write simple commands.
Goals
The commands on the IPython shell cover:
Warming up
Enter Python in the interactive mode. You should see a message
In [1]:
In [1]: 1 + ___
Out[1]: 3
In [2]: 12 ___ 8
Out[2]: 4
In [3]: ___ * 5
Out[3]: 20
In [4]: 21 / 7
Out[4]: ___
In [5]: ___ ** 2
Out[5]: 81
Enter the commands to see what happens (do not type the first part In [1] etc., these will
appear automatically).
Exercises
Complete the following exercises:
Exercise 1:
There are more operators in Python. Find out what the following operators do?
3 ** 3
24 % 5
23 // 10
Exercise 2:
Which of the following Python statements are valid? Try them in the IPython shell.
0 + 1
2 3
4-5
6 * * 7
8 /
9
Exercise 3:
Which operations result in 8?
[] 65 // 8
[] 17 % 9
[] 2 ** 4
[] 64 ** 0.5
name number
Jacob 34465
Michael 32025
Matthew 28569
Joshua 27531
Christopher 24928
Storing numbers
The U.S. authorities record the names of all babies born since 1880. How many babies with
more or less popular names were born in 2000? Let's store the numbers in variables.
Warming up
Let's define some variables:
In [9]: all_babies = 0
In [10]: all_babies = _____ + _____ + _____
In [11]: all_babies
Out[11]: 49031
Insert the correct values and variable names into the blanks.
Exercises
Complete the following exercises:
Exercise 1:
Which of the following variable names are correct? Try assigning some numbers to them.
Storing numbers 12
Tutorial de Conceitos Básicos do Python 3
Emily
EMILY
emily brown
emily25
25emily
emily_brown
[Link]
Exercise 2:
Which are correct variable assignments?
[] a = 1 * 2
[] 2 = 1 + 1
[] 5 + 6 = y
[] seven = 3 * 4
Storing numbers 13
Tutorial de Conceitos Básicos do Python 3
Storing text
Warming up
So far, we have only worked with numbers. Now we will work with text as well.
first = 'Emily'
last = "Smith"
first
last
name[0]
name[3]
name[-1]
Exercises
Exercise 1:
Is it possible to include the following special characters in a string?
Exercise 2:
What do the following statements do?
Storing text 14
Tutorial de Conceitos Básicos do Python 3
first = `Hannah`
first = first[0]
name = first
name = ""
Exercise 3:
Explain the code
text = ""
characters = "ABC"
text = characters[0] + text
text = characters[1] + text
text = characters[2] + text
text
The Challenge
first name Andrew
last name O'Malley
gender M
year of birth 2000
Write the information from each row of the table into a separate string variable, then
combine them to a single string, e.g.:
Storing text 15
Tutorial de Conceitos Básicos do Python 3
Warming up
Now we are going to combine strings with integer numbers.
Insert into the following items into the code, so that all statements are working: age ,
int(age) , name, str(born) , 2000
Questions
Can you leave str(born) and int(age) away?
What do str() and int() do?
Exercises
Exercise 1:
What is the result of the following statements?
9 + 9
9 + '9'
'9' + '9'
Exercise 2:
Change the statements above by adding int() or str() to each of them, so that the result is 18
or '99', respectively.
Exercise 3:
Explain the result of the following operations?
9 * 9
9 * '9'
'9' * 9
Exercise 4:
Write Python statements that create the following string:
12345678901234567890123456789012345678901234567890
age 15 integer
Write the values from each row of the table into string or integer variables, then combine
them to a single one-line string.
In the second part of the tutorial, you will learn a basic set of Python commands.
Theoretically, they are sufficient to write any program on the planet (this is called Turing
completeness).
Practically, you will need shortcuts that make programs prettier, faster, and less painful to
write. We will save these shortcuts for the later parts.
Goals
The new Python commands cover:
Warming up
Open a text editor window (not a Python console). Type:
print("Hannah")
print(23073)
python3 first_program.py
Exercises
Exercise 1
Explain the following program:
name = "Emily"
year = 2000
print(name, year)
Exercise 2
Write into a program:
name = "Emily"
name
What happens?
Exercise 3
Which print statements are correct?
[] print("9" + "9")
[] print "nine"
[] print(str(9) + "nine")
[] print(9 + 9)
[] print(nine)
Extra challenges:
Use a single print statement to produce the output.
Store the names in separate variables first, then combine them.
Use string formatting.
Warming up
What happens when you write the follwing lines in the IPython shell:
In [1]: a = input()
In [2]: a
Exercise 1
Which input statements are correct?
[] a = input()
[] a = input("enter a number")
[] a = input(3)
Extra challenge:
Add 1 to the age entered.
Repeating instructions
So far, each Python instruction was executed only once. That makes programming a bit
useless, because our programs are limited by our typing speed.
In this section you will learn the for statements that repeats one or more instructions
several times.
Warming up
What does the following program do?
What advantages does this (apparently more complex) program have over this one:
print('E')
print('m')
print('i')
print('l')
print('y')
Exercises
Exercise 1
What does the following program do?
text = ""
characters = "Hannah"
for char in characters:
text = char + text
print(text)
Exercise 2
Write a for loop that creates the following output
Repeating instructions 22
Tutorial de Conceitos Básicos do Python 3
000
111
222
333
444
555
666
777
888
999
Exercise 3
Write a for loop that creates the following string variable:
000111222333444555666777888999
Exercise 4
Write a for loop that creates the following output
1
3
6
10
15
21
28
Exercise 5
Write a for loop that creates the following string
"1 4 9 16 25 36 49 64 81 "
Exercise 6
Add a single line at the end of the program, so that it creates the following string:
"1 4 9 16 25 36 49 64 81"
Exercise 7
Repeating instructions 23
Tutorial de Conceitos Básicos do Python 3
[] for i in range(10):
[] for k in 3+7:
Extra challenge
Duplicate each character, so that Emily becomes EEmmiillyy .
Repeating instructions 24
Tutorial de Conceitos Básicos do Python 3
Warming up
Find out what each of the expressions does to the list in the center.
Exercises
Exercise 1
What does the list b contain?
a = [8, 7, 6, 5, 4]
b = a[2:4]
[] [7, 6, 5]
[] [7, 6]
[] [6, 5]
[] [6, 5, 4]
Exercise 2
Use the expressions to modify the list as indicated. Use each expression once.
Exercise 3
Use the expressions to modify the list as indicated. Use each expression once.
name number
Jacob 34465
Michael 32025
Matthew 28569
Joshua 27531
Christopher 24928
Nicholas 24650
Andrew 23632
Joseph 22818
Daniel 22307
Tyler 21500
Hint
If you are using Python2, you need to specify whether you want numbers with decimal
places when dividing. That means
3 / 4
3.0 / 4
Making decisions
The last missing piece in our basic set of commands is the ability to make decisions in a
program. This is done in Python using the if command.
Warming up
Add your favourite movie to the following program and execute it:
Exercises
Exercise 1
Which of these if statements are syntactically correct?
[] if a and b:
[] if len(s) == 23:
[] if a ** 2 >= 49:
[] if a != 3
Exercise 2
Write a program that lets the user enter a number on the keyboard. Find the number in the
list that is closest to the number entered and write it to the screen.
Making decisions 29
Tutorial de Conceitos Básicos do Python 3
Extra challenge
count the number of names starting with A and print that number as well.
Making decisions 30
Tutorial de Conceitos Básicos do Python 3
Goals
read text files
write text files
extract information from a file
list all files in a directory
Warming up
Match the descriptions with the Python commands.
Exercise 1:
Make the program work by inserting close , line , [Link] , print into the gaps.
f = open(___)
for ____ in f:
____(line)
f.____()
Exercise 2
Write a program that counts the number of names in the file [Link] from the dataset
of baby names.
Exercise 3
Execute the following program. What does it calculate?
boys = 0
for line in open('[Link]'):
if ",M," in line:
boys = boys + 1
Exercise 4
How many different names starting with an M were there in 2014?
Exercise 5
How many different girls names starting with an M were there in 2014?
Warming up
Execute the following program. Explain what happens.
f = open('boy_names.txt', 'w')
for name in names:
[Link](name + '\n')
[Link]()
Remove the + '\n' from the code and run the program again. What happens?
Exercise 1
Which are correct commands to work with files?
[] f = open(filename, 'w')
[] open(filename).writelines(out)
[] [Link]()
Write a program that writes all names into a single text file.
Extra Challenges
Warming up
Create a text file in a text editor. Write the following line there:
Alice Smith;23;Macroeconomics
f = open('[Link]')
print(f)
text = [Link]()
print(text)
columns = [Link]().split(';')
print(columns)
name = columns[0]
age = int(columns[1])
studies = columns[2]
print(name)
print(age)
print(studies)
What happens?
Exercises
Exercise 1
What does the following line produce?
File parsing 36
Tutorial de Conceitos Básicos do Python 3
"Take That".split('a')
Exercise 2
Create a text file with the contents:
Alice Smith;23;Macroeconomics
Bob Smith;22;Chemistry
Charlie Parker;77;Jazz
Write a program that reads all names and puts them into a list. Print the list.
Exercise 3
Collect the ages into a separate list.
Exercise 4
Collect the occupations into a separate list.
Exercise 5
Leave the strip() command away from the above program. What happens?
Extra Challenge:
Calculate the total number of babies registered in 2014.
File parsing 37
Tutorial de Conceitos Básicos do Python 3
Warming up
Fill in the gaps
Exercise 1
Explain the following code:
import os
for dirname in [Link]('.'):
print(dirname)
Exercise 1
Write a program that counts the number of files in the unzipped set of baby names. Have the
program print that number.
Exercise 2
How many entries (lines) does the entire name dataset have?
Hint: Generate a message that tells you which file the program is reading.
Exercise 3
Write a program that finds the most frequently occuring name in each year and prints it.
The Challenge
Find and print your name and the according number in each of the files, so that you can see
how the number changes over time.
Functions
Python 3.5 has 72 builtin functions. To start writing useful programs, knowing about 25 of
them is sufficient. Many of these functions are useful shortcuts that make your programs
shorter.
Builtin functions 40
Tutorial de Conceitos Básicos do Python 3
String methods
Exercise
Find out what each of the expressions does to the string in the center.
Definitions
String methods
Every string in Python brings a list of functions to work with it. As the functions are contained
within the string they are also called methods. They are used by adding the . to the string
variable followed by the method name.
Changing case:
String functions 41
Tutorial de Conceitos Básicos do Python 3
[Link]()
[Link](' ')
[Link]('ing')
The method returns the start index of the match. The result -1 means that no match has
been found.
Replacing substrings:
[Link]('Strings','text')
[Link]('Man')
[Link]('ings')
String functions 42
Tutorial de Conceitos Básicos do Python 3
Introspection
Warming up
Try the following on the interactive shell:
import random
dir(random)
help([Link])
name = [Link](['Hannah', 'Emily', 'Sarah'])
type(name)
Extra challenges:
let the user choose the gender of the babies.
let the user enter how many babies they want to have.
load baby names from a file.
Introspection 43
Tutorial de Conceitos Básicos do Python 3
Data types
Match the data samples with their types.
Dictionaries
Using a dictionary
Find out what each of the expressions does to the dictionary in the center.
Definitions
Dictionaries
Dictionaries are an unordered, associative array. They have a set of key/value pairs. They
are very versatile data structures, but slower than lists. Dictionaries can be used easily as a
hashtable.
Creating dictionaries
Dictionaries 45
Tutorial de Conceitos Básicos do Python 3
prices = {
'banana':0.75,
'apple':0.55,
'orange':0.80
}
Methods of dictionaries
There is a number of functions that can be used on every dictionary:
prices.has_key('apple')
[Link]('banana')
[Link]('kiwi')
Dictionaries 46
Tutorial de Conceitos Básicos do Python 3
[Link]('kiwi', 0.99)
[Link]('banana', 0.99)
# for 'banana', nothing happens
print [Link]()
print [Link]()
print [Link]()
Exercises
Exercise 1.
What do the following commands produce?
[] False
[] "B"
[] True
[] 1
Exercise 2.
What do these commands produce?
[] 1
[] True
[] "B"
[] False
Exercise 3.
What do these commands produce?
Dictionaries 47
Tutorial de Conceitos Básicos do Python 3
[] True
[] ['A', 1, True]
[] 3
Exercise 4.
What do these commands produce?
[] ['A', 'B', 1]
Exercise 5.
What do these commands produce?
[] None
[] 'C'
[] an Error
[] False
Exercise 6.
What do these commands produce?
[] 3
Dictionaries 48
Tutorial de Conceitos Básicos do Python 3
[] 'C'
[] None
[] an Error
Dictionaries 49
Tutorial de Conceitos Básicos do Python 3
Tuples
A tuple is a sequence of elements that cannot be modified. They are useful to group
elements of different type.
t = ('bananas','200g',0.55)
Exercises
Exercise 1
Which are correct tuples?
[] (1, 2, 3)
[] ("Jack", "Knife")
[] [1, "word"]
Exercise 2
What can you do with tuples?
[] sort them
Tuples 50
Tutorial de Conceitos Básicos do Python 3
Exercise
Match the expressions so that the while loops run the designated number of times.
While loops combine for and if . They require a conditional expression at the beginning.
The conditional expressions work in exactly the same way as in if.. elif statements.
i = 0
while i < 5:
print (i)
i = i + 1)
while 51
Tutorial de Conceitos Básicos do Python 3
Exercises
Exercise 1
Which of these while commands are correct?
[] while a = 1:
[] while b == 1
[] while a + 7:
Exercise 2
Which statements are correct?
Exercise 3
The following for loop searches for 33 in the data. Change the code so that it uses a
while loop instead.
found = False
for n in data:
if n == 33:
found = True
Exercise 4
while 52
Tutorial de Conceitos Básicos do Python 3
The following while loop counts numbers higher than 10. Change the code so that it uses
a for loop instead.
i, j = 0,0
while i < len(data):
if data[i] > 10:
j += 1
i += 1
Exercise 5
Will the following while loop finish?
count = 0
while count > 0:
print count
count += 1
Exercise 6
Will the following while loop finish?
text = "a"
while "z" not in text:
text += "a"
Exercise 7
Will the following while loop finish? than a = 7 b = 135 while a != b: a += (a - b) / 10.0 b -=
(a - b) / 10.0
Exercise 8
Will the following while loop finish?
n = 0
while n * 5 != n ** 2:
n += 2
while 53
Tutorial de Conceitos Básicos do Python 3
Exercise 9
Will the following while loop finish?
data = [1,2,7,8]
while data[-1] > 2:
[Link]()
Exercise 10
Will the following while loop finish?
data = [2,3,15]
while data[0] < 100:
data = data[1:]
while 54
Tutorial de Conceitos Básicos do Python 3
Tables
Exercise 1:
Create an empty table of 10 x 10 cells.
Exercise 2:
Fill the table with the numbers from 1 to 100.
Exercise 3:
Save the table to a file.
Exercise 4:
Calculate the average number from the count column for a file with baby names for the year
2000 and print it.
Exercise 5:
Calculate the standard deviation as well.
Exercise 6:
Calculate how many girls' names and boys' names are there in total in 1900 and in 2000.
Tables 55
Tutorial de Conceitos Básicos do Python 3
Structuring programs
In Python, you can structure programs on four different levels: with functions, classes,
modules and packages. Of these, classes are the most complicated to use. Therefore they
are skipped in this tutorial.
Goals
Learn to write functions
Learn to write modules
Learn to write packages
Know some standard library modules
Know some installable modules
Modules
What is a module?
Any Python file (ending .py) can be imported from another Python script. A single Python file
is also called a module.
Importing modules
To import from a module, its name (without .py) needs to be given in the import statement.
Import statements can look like this:
import fruit
import fruit as f
from fruit import fruit_prices
from my_package.fruit import fruit_prices
It is strongly recommended to list the imported variables and functions explicitly instead of
using the import * syntax. This makes debugging a lot easier.
When importing, Python generates intermediate code files (in the pycache directory) that
help to execute programs faster. They are managed automatically, and dont need to be
updated.
Modules 57
Tutorial de Conceitos Básicos do Python 3
Exercises
Exercise 1
Join the right halves of sentences.
Exercise 2
Which import statements are correct?
[] import re
[] import [Link]
[] from re import *
Exercise 3
Packages 58
Tutorial de Conceitos Básicos do Python 3
Exercise 4
Which statements about packages are true?
Exercise 5
Which packages are installed by default?
Packages 59
Tutorial de Conceitos Básicos do Python 3
Additional Exercises
Exercise 1
Calculate the total number of births for the years 1900 and 2000.
Exercise 2
Read the Baby names from 1900 to 2000. How many different names per year are there?
Create a bar plot with distinct bars for girls/boys.
Exercise 3
How many baby names are there in 1900 and 2000 beginning with A or Z , respectively?
Exercise 4
Create a plot showing how the last letters of names change over time.
Exercise 5
Schreibe ein Programm, das den Mittelwert der Daten in der Datei datei_lesen/[Link]
berechnet.
Exercise 6
Schreibe den Mittelwert in eine Datei.
Exercise 7
Berechne ausserdem die Standardabweichung. Verwende:
import math
wurzel = [Link](wert)
Additional Exercises 60
Tutorial de Conceitos Básicos do Python 3
Review Questions
TODO: sort basic/advanced questions apart
How can you swap the values of two variables? How can you create a dictionary with some
values inside? How do the methods get(), has_key() and keys() of a dictionary differ? How
can you retrieve values from a dictionary when you do not know whether their keys exist?
How can you set values in a dictionary? What is a list comprehension? Is it possible to
create a for loop over a dictionary? How to sort values from a dictionary? What is the
dir(object) built-in function good for? What does the getattr(object,name) built-in function
return? How can i execute a string containing Python code created by a Python program?
What can you do to make your programs run faster? What can i use to calculate with
numbers? Write down at least 5 python commands. What can i do to manipulate strings?
Write down at least 5 python commands. What can i do with lists? Write down at least 5
python commands. What can i do with dictionaries? Write down at least 5 python
commands.
How can you: Swap the values of two variables (Python Cookbook 1.2) Create a dictionary
(Python Cookbook 1.3) Retrieve values from a dictionary (Python Cookbook 1.4) Set values
in a dictionary (Python Cookbook 1.5) Loop through a list I (Python Cookbook 1.14) Loop
through a list II (Python Cookbook 1.15) Loop through a text file (Python Cookbook 4.2). Sort
values from a dictionary (Python Cookbook 2.2) Sorting list of objects by an attribute (Python
Cookbook 2.8) String handling (Python Cookbook 3.2-3.11) Test if a string can be converted
to an integer (Python Cookbook 3.13) Write a text file (Python Cookbook 4.3) Replace text in
a file (Python Cookbook 4.4)
You have an integer variable a, and four different functions that should be called depending
on the value of a. How would you implement this? What does the assert statement do? What
kinds of operations should be wrapped in a try.. except clause. How to create an exception
on purpose? Write two different ways to calculate the numbers from 1 to 10. Write two
different ways to call [Link] for each element of a list. What different kinds of
arguments can a function definition contain? Which data types as function arguments are
mutable, which are immutable? For how long does a local variable defined in a function
Review Questions 61
Tutorial de Conceitos Básicos do Python 3
exist? What is a function variable good for? What are rules for good style of functions?
When a module is importet by three other modules in one program, how often is its
initialization code run? Name two different kinds of import statements. What is a package?
Where does Python look for module files available for import?
Objects An object is a container for data plus code. Name three advantages of writing
programs with objects. What is a class? What is an instance? How does a constructor
method look like? What are class attributes, what instance attributes? Explain how
inheritance works using the classes 'Plant', 'Vegetable', 'Carrot' and 'Cactus' and the
methods 'grow()', 'hurt()' or 'eat()'? Data types and structures What kinds of values can the
basic data types (boolean, integer, float and string) take? What is a type cast and how is it
written in Python? What is the difference between a tuple and a list? Which values of these
data types are equivalent to None? Which values of these data types are equal to a boolean
True? Enumerate five useful things that you can do with lists. How to make a copy of an
entire list? How to loop through all elements of a dictionary? How to check whether a
dictionary has a certain key? What data types work as keys of a dictionary? What is the
difference between a stack and a queue? How many leafs has a binary tree with 7 nodes?
Give an example of a graph. Operations What is a floor division? How is it used in Python?
Where to look for the sine, cosine and square root functions? What do programmers need to
take care of when doing divisions? What needs to be done before using the arithmetic
operators (+, -, , /) on Python objects? Give an expression that checks whether a number is
odd or even. Does the arithmetic (+, -, , /) or the AND operator have the higher priority?
What does the expression x<7 AND „small“ OR „big“ return? Is an expression always
evaluated completely? How can you check whether a number variable is between two
values? How to cut off the last two characters of a string? How to replace the letter A with B
in a string? How to make a list of string variables from a tab-separated string? How to find
out if a string starts with a decimal number? Enumerate some elements of the regular
expression syntax. Are string functions or regular expressions faster? Give a line of code
that writes a list of strings to a file. What parameters does the format string „%i str: %s
%4.3f“ expect? How to read text from the keyboard? What do the escape characters \t and
\n stand for? Propose three different ways to write data to a file.
Where in your programs should you put triple-quoted documentation strings? Which method
is called if you convert an object to a string? What do you see when reading the doc string
of a function, a module or an object?
What is a profiler?
Review Questions 62
Tutorial de Conceitos Básicos do Python 3
Review Questions 63
Tutorial de Conceitos Básicos do Python 3
What is Python?
Python is an interpreted language.
Python uses dynamic typing.
Python 3 is not compatible to Python 2.x
The Python interpreter generates intermediate code (in the pycache directory).
Strengths
Quick to write, no compilation
Fully object-oriented
Many reliable libraries
All-round language
100% free software
Weaknesses
Writing very fast programs is not straightforward
No strict encapsulation
Paper books
Managing your Biological Data with Python - Allegra Via, Kristian Rother and Anna
Tramontano
Data Science from Scratch - Joel Grus
Websites
Main documentation and tutorial: [Link]
Tutorial for experienced programmers: [Link]
Tutorial for beginners: [Link]
Comprehensive list of Python tutorials, websites and books:
[Link]
Python Library Reference covering the language basics:
[Link]
Global Module Index – description of standard modules: [Link]
[Link]
Authors
© 2013 Kristian Rother (krother@[Link])
This document contains contributions by Allegra Via, Kaja Milanowska and Anna Philips.
License
Distributed under the conditions of a Creative Commons Attribution Share-alike License 3.0.
Acknowledgements
I would like to thank the following people for inspiring exchange on training and Python that
this tutorial has benefited from: Pedro Fernandes, Tomasz Puton, Edward Jenkins, Bernard
Szlachta, Robert Lehmann and Magdalena Rother
Acknowledgements 66