Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introdução ao Python
Search
Diogo Leal
October 29, 2014
Programming
0
59
Introdução ao Python
Treinamento interno sobre a linguagem Python para todos os funcionários da InfoLink.
Diogo Leal
October 29, 2014
Tweet
Share
More Decks by Diogo Leal
See All by Diogo Leal
Desmistificação do Docker
diogoleal
0
70
Fuja da Gambiarra antes que ela te alcance!
diogoleal
0
140
Automatização - A arte da preguiça
diogoleal
0
62
Apachev8 em um Fusquina 67
diogoleal
0
38
Jabber/XMPP
diogoleal
0
73
Other Decks in Programming
See All in Programming
All About Angular's New Signal Forms
manfredsteyer
PRO
0
110
株式会社 Sun terras カンパニーデック
sunterras
0
270
非同期jobをtransaction内で 呼ぶなよ!絶対に呼ぶなよ!
alstrocrack
0
690
After go func(): Goroutines Through a Beginner’s Eye
97vaibhav
0
360
Catch Up: Go Style Guide Update
andpad
0
210
NetworkXとGNNで学ぶグラフデータ分析入門〜複雑な関係性を解き明かすPythonの力〜
mhrtech
3
1.2k
いま中途半端なSwift 6対応をするより、Default ActorやApproachable Concurrencyを有効にしてからでいいんじゃない?
yimajo
2
400
XP, Testing and ninja testing ZOZ5
m_seki
3
600
overlayPreferenceValue で実現する ピュア SwiftUI な AdMob ネイティブ広告
uhucream
0
180
CSC509 Lecture 04
javiergs
PRO
0
300
(Extension DC 2025) Actor境界を越える技術
teamhimeh
1
250
理論と実務のギャップを超える
eycjur
0
120
Featured
See All Featured
Being A Developer After 40
akosma
91
590k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
51k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
620
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Build your cross-platform service in a week with App Engine
jlugia
232
18k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Code Reviewing Like a Champion
maltzj
525
40k
Transcript
Python Diogo Leal
[email protected]
Programar é uma das melhores coisas para se fazer vestido!
Julio Cezar Neves
Python?
Muito fácil de aprender
Linguagem de altíssimo nível
Multiplataforma
Multiparadigma
Interpretada
FLOSS
Mais com menos
Ótima documentação
Excelente comunidade.
Quem usa Python?
https://www.python.org/about/success/
O Interpretador
Alguns detalhes...
Case sensitive
Tipagem Dinamica
a = 1 b = 'alguma coisa' c = 2.3
Tudo é objeto
#Comentários
Variaveis
comeco = "Alo mundo!"
string = 'Alo mundo!'
numero = 42
float = 5.239
valor = True
valor = False
type()
Operadores Aritiméticos
+, -, *, /, //, **, %
a = 1 b =2 a + b
a - b
a * b
a / b
divisão inteira a // b
Exponenciação a ** b
Resto da divisão 10%3
(50 - 5 * 6) /4
Operadores Lógicos
and, or, not
Operadores Relacionais
>, <, >=, <=, ==, !=, <>
Strings
"alo mundo!"
'alo mundo!'
Operações com string
+ e *
terca = 'pizza' 'quero ' + terca
terca = 'pizza' terca * 3
Metodos de Strings
split()
a = '1+2+3+4+5+6' a.split('+')
len()
hoje = 'pizza' len(hoje)
strip()
hoje = '#pizza#' hoje.strip('#')
find()
sabores = 'portuguesa, catuperoni, salaminho, calabresa, napolitano' sabores.find('portuguesa ')
lower(), upper()
a = 'GRITAR EH FEIO' a.lower()
a = 'mas tem gente que eh movido a esporro'
a.upper()
Usando um editor de texto
sublime, vim, emacs gedit,
Use a extensao .py
Cabeçalho
#!/usr/bin/env python
#!/usr/bin/python
#!/usr/bin/python2
#!/usr/bin/python #-*- coding: utf-8 -*-
Executando
chmod +x arquivo.py
python arquivo.py ou ./arquivo.py
print()
print "alo mundo!"
hoje = 'um lindo dia feliz' print hoje
Condicionais
if, elif e else
if hoje == 'terca': print 'tem pizza' else: print 'maldito
dia'
None
while e else
x = 0 while x < 10: print x, x
+= 1
None
loops
for
for i in 'string': print i,
for i in range(1, 30): print i,
Listas
lista = [1, 2, 3, 4, 5]
lista.append(0)
lista.insert(1,'aqui' )
lista.remove('aqui')
lista.pop(1) lista.pop()
lista.count(1)
lista.index(1)
lista.reverse()
lista.sort()
Truplas
tupla = (1, 2, 3) ou tupla = 1,2,3
Dicionário
dicionario = {'lingua': 'python', 'versao': 2.7}
dicionario['os'] = 'linux'
dicionario.pop('os') ou dicionario.pop('os', 'nao tem nada')
dicionario.clear()
dicionario['versao']
dicionario.get['versao'] ou dicionario.get['versao', 'vazio']
dicionario.has_key['versao']
Funções
def olamundo(): print 'ola mundo'
Parametro de funções
def maximo(a, b): if a > b: print a, 'eh
maior' else: print a, 'eh menor' maximo(5, 7)
Variaveis locais
def maximo(a, b): if a > b: print a, 'eh
maior' else: print a, 'eh menor' a = 4 maximo(5, 7)
Variaveis globais
def funcao(): global x print 'x eh ', x x
= 2 print 'variavel x mudou:' , x x = 50 funcao()
return
def maximo(a, b): if a > b: return a else:
return b print maximo(5, 7)
Exceções
try: print "ola mundo!" except: print "excecao"
import modulo
import os os.mkdir('/infolink/')
Isso é apenas uma introdução a Python!
None