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
74
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introdução ao Python
Treinamento interno sobre a linguagem Python para todos os funcionários da InfoLink.
Diogo Leal
October 29, 2014
More Decks by Diogo Leal
See All by Diogo Leal
Desmistificação do Docker
diogoleal
0
89
Fuja da Gambiarra antes que ela te alcance!
diogoleal
0
170
Automatização - A arte da preguiça
diogoleal
0
81
Apachev8 em um Fusquina 67
diogoleal
0
57
Jabber/XMPP
diogoleal
0
91
Other Decks in Programming
See All in Programming
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
720
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
1
140
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
130
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
310
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
500
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
700
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
430
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
330
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
660
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
5
1.9k
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
200
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.7k
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
440
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Between Models and Reality
mayunak
4
390
How to Talk to Developers About Accessibility
jct
2
520
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
490
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
The Curse of the Amulet
leimatthew05
2
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
480
Statistics for Hackers
jakevdp
799
230k
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