This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
palavra_chave = ['uva', 'limao', 'laranja', 'pera', 'maca', 'caju'] | |
recurso = ['limao', 'pera' ] | |
palavra_set=set(palavra_chave) | |
recurso_set=set(recurso) | |
sobra=palavra_set-recurso_set | |
print sobra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, unicode_literals | |
CADERNOS = [[13, 8, 19], | |
[3, 18, 4], | |
[14, 9, 20], | |
[14, 8, 10], | |
[1, 7, 2], | |
[3, 2, 10], | |
[10, 16, 7], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fatorial(n): | |
def multiplicar(acumulador, elemento): | |
return acumulador * elemento | |
return reduce(multiplicar, xrange(1, n + 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, unicode_literals | |
QTD_INICIAL_DE_NOTAS = 10 | |
NOTAS = [5, 10, 20, 50] | |
def sacar_recursiva(valor, saque, notas_disponiveis, qtdes_disponiveis): | |
# Se valor é 0, entao retorno é saque atual como resposta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import izip | |
lista=range(5) | |
for elemento, proximo_elemento in izip(lista[:-1],lista[1:]): | |
print elemento,proximo_elemento | |
# Resultado | |
# 0 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#decorator 1 | |
from datetime import datetime | |
import functools | |
import logging | |
def query_checker(*keys_to_check): | |
""" Checks if a given key exists in the query string dictionary, if not, never executes the real handler and return status 400 """ | |
def real_decorator(func): | |
@functools.wraps(func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Categoria | |
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, unicode_literals | |
from google.appengine.ext import ndb | |
class Categoria(ndb.Model): | |
descricao=ndb.StringProperty() | |
tipo=ndb.StringProperty() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = """{u'search_metadata': {u'count': 100, u'completed_in': 0.23599999999999999, u'max_id_str': u'407528290757668864', u'since_id_str': u'0', u'next_r | |
esults': u'?max_id=407528086326870015&q=%23PlateiaLuanSantana&count=100&include_entities=1', u'refresh_url': u'?since_id=407528290757668864&q=%2 | |
3PlateiaLuanSantana&include_entities=1', u'since_id': 0, u'query': u'%23PlateiaLuanSantana', u'max_id': 407528290757668864}, u'statuses': [{u'co | |
ntributors': None, u'truncated': False, u'text': u'#PlateiaLuanSantana NUNCA FUI POR FAVOR ME SORTEIA @CFLuanSantana u', u'in_reply_to_status_id | |
': None, u'id': 407528290757668864, u'favorite_count': 0, u'source': u'<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for i | |
Phone</a>', u'retweeted': False, u'coordinates': None, u'entities': {u'symbols': [], u'user_mentions': [{u'id': 177021046, u'indices': [51, 65], | |
u'id_str': u'177021046', u'screen_name': u'CFLuanSantana', u'name': u'Central de f\xe3s LS.'}], u'hashtags': [{u'indices': [0, 19], u'text': u' | |
Pla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def executador_de_funcao(fcn): | |
return fcn() | |
def a(): | |
return 'A' | |
def b(): | |
return 'B' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numeros = [int(input('Digite um numero: ')) for i in range(5)] | |
print(numeros) |
OlderNewer