porque python é legal! d
DESCRIPTION
Show how cool is python, simple example, basic functions, language structure, include batteries, and some codes examples.TRANSCRIPT
![Page 1: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/1.jpg)
Porque Python é Legal:D
Joelmir Ribacki
![Page 2: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/2.jpg)
Quem é Joelmir?
● Cursando Bacharel em Ciência da Computação na UCS● 6 anos trabalhando na área de TI
○ últimos 4 em desenvolvimento● Participante do Tchêlinux desde 2009● Python desde 2010 ( e nunca mais parei )● Já trabalhei com Oracle, .NET, PHP, Ruby
○ Atualmente com Python.● Python me salvou em várias durante a vida acadêmica● Conheci muita gente legal por causa do python
![Page 3: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/3.jpg)
Da onde Python?
● Origem no nome Python, Monty Python (spam, spam … )
![Page 4: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/4.jpg)
Quem e qual motivo?
Python foi criada por Guido Van Rossum em um lapso de tempo entre 1989 e 1991 com o objetivo de suprir a necessidade que a linguagem ABC na época não tinha de interagir com o sistema operacional, e o principal foco de aumentar a produtividade do programador.
![Page 5: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/5.jpg)
Python é Legal, já vem com baterias
Alguns modulos inclusos:● XML HTLM● envio de e-mail● protocolos (HTTP, UDP…)● Threads● funções mantematicas● mais um caminhão de coisas.
Alguns modulos adicionaveis● área científica como numpy
SciPy● área web como django flask
plone,● área gráfica com pil
pyOpenGL● e mais o que imaginar.
>>> import antigravity
![Page 6: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/6.jpg)
Python é multi plataforma
Sistemas Unix e derivados como OSX já vem com python default instalado, novos linux python já é uma dependencia necessária para funcionar o SO.
$ pythonPython 2.7.5 (default, Nov 12 2013, 16:18:42)[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>>
PS: Funciona no windows também ( só instalar e ser feliz )
![Page 7: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/7.jpg)
Foco na solução!
● Multi paradigma● Tudo é objeto● Tipagem forte e dinâmica● Interpretador iterativo● Indentação● Documentação● Comunidade ativa
● Python é Legal!
![Page 8: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/8.jpg)
Python funciona auto magicamente
● Primeiro exercicio de programação:>>> print 'Olá mundo'Olá mundo● Segundo exercicio de programação:>>> a = 1>>> b = 2>>> aux = a>>> a = b>>> b = aux>>> print a, b2 1
![Page 9: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/9.jpg)
Mas não era uma simples troca de valores????
>>> a,b = 1,2>>> print a , b1 2>>> a,b = b,a>>> print a , b2 1
Opsss….
![Page 10: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/10.jpg)
Python se preocupa com você
Ou somente …
![Page 11: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/11.jpg)
Python é mais que um canivete suíço:
![Page 12: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/12.jpg)
Criando um serviço RPC
Servidor
Cliente
![Page 13: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/13.jpg)
Operações com arquivos
Leitura
Escrita
![Page 14: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/14.jpg)
Avião 3D com pyopengl
![Page 15: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/15.jpg)
Django$pip install django
django-admin.py startproject pysm
$cd pysm
$python manage.py runserver
![Page 16: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/16.jpg)
IPython$ipython
In [1]: pysm = 'some_string'In [2]: type(pysm)
Out[2]: str
In [3]: pysm.pysm.capitalize pysm.expandtabs pysm.isdigit pysm.ljust pysm.rindex pysm.splitlines pysm.upper pysm.center pysm.find pysm.islower pysm.lower
pysm.rjust pysm.startswith pysm.zfill pysm.count pysm.format pysm.isspace pysm.lstrip pysm.rpartition pysm.strip pysm.decode pysm.index pysm.istitle pysm.partition pysm.rsplit pysm.swapcase pysm.encode pysm.isalnum pysm.isupper pysm.replace pysm.rstrip
pysm.title pysm.endswith pysm.isalpha pysm.join pysm.rfind pysm.split pysm.translate
![Page 17: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/17.jpg)
Propertiesclass C(object): def __init__(self): self._x = None
def getx(self): return self._x def setx(self, value): self._x = value def delx(self): del self._x x = property(getx, setx, delx, "I'm the 'x' property.")
class C(object): def __init__(self): self._x = None
@property def x(self): """I'm the 'x' property.""" return self._x
@x.setter def x(self, value): self._x = value
@x.deleter def x(self): del self._x
![Page 18: Porque python é legal! d](https://reader035.vdocuments.net/reader035/viewer/2022081404/55919b581a28ab42448b45fa/html5/thumbnails/18.jpg)
sort e reverse
>>> valores = [123, 'xyz', 'zara', 'abc', 'xyz']>>> valores.sort()>>> print "ordenados : ", valores
ordenados : [123, 'abc', 'xyz', 'xyz', 'zara']
>>> valores = [123, 'xyz', 'zara', 'abc', 'xyz']>>> valores.reverse()>>> print "ordenados : ", valores
ordenados : ['xyz', 'abc', 'zara', 'xyz', 123]