This file contains hidden or 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
#feito por https://twitter.com/guilhermeslcs | |
class Professor: | |
def __init__(self, nome, instituto, funcao, salario): | |
self.nome = nome | |
self.instituto = instituto | |
self.funcao = funcao | |
self.salario = salario | |
f = open("salarios.txt", "r") |
This file contains hidden or 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
""" | |
Autores: | |
Tiago Henrique da Cruz Pereira | |
João Felipe de Moraes Borges | |
""" | |
import threading | |
import time | |
import os | |
from urllib.request import urlopen |
This file contains hidden or 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
n = 908007000 | |
print (len(str(n)) - len(str(int(str(n)[::-1])))) | |
print (len(str(n)) - len(str(n).rstrip('0'))) | |
from itertools import takewhile | |
l = str(n).split('0') | |
print(len(list(takewhile(lambda x: not x, reversed(l))))) | |
import re | |
print(len(re.findall('0*$',str(n))[0])) | |
f = lambda m: (lambda g: g(m, g))(lambda n, f: 1 + f(n // 10, f) if n % 10 == 0 else 0) | |
print (f(n)) |
This file contains hidden or 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
s1 = 'abacate' | |
s2 = 'palmeiras' | |
f1 = len(s1) | |
f2 = len(s2) | |
s = '' | |
for k in range(min(f1, f2)): | |
s += s1[k] | |
s += s2[k] | |
k += 1 | |
s += s1[k:] if f1 > f2 else s2[k:] |
This file contains hidden or 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
n = int(input('N: ')) | |
primo = True | |
for k in range(2, n): | |
if n % k == 0: | |
primo = False | |
break | |
if primo: print ('Primo') |
This file contains hidden or 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 uber_rides.session import Session | |
from pprint import pprint | |
session = Session(server_token='sua chave da API') | |
from uber_rides.client import UberRidesClient | |
client = UberRidesClient(session) | |
response = client.get_price_estimates( | |
start_latitude=-23.202480, | |
start_longitude=-45.903285, |
This file contains hidden or 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
import requests | |
import json | |
url = 'http://swapi.co/api/species/' | |
for d in range(1, 5): | |
d = '' if d == 1 else '?page='+str(d) | |
res = requests.get(url+str(d)) | |
res = json.loads(res.content.decode('utf-8')) | |
for specie in res['results']: | |
print (specie['name'], specie['classification'], |
This file contains hidden or 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
#baseado em https://blogs.worldbank.org/opendata/accessing-world-bank-data-apis-python-r-ruby-stata | |
import wbdata | |
import matplotlib.pyplot as plt | |
#set up the countries I want | |
countries = ["CL","UY","BR"] | |
#set up the indicator I want (just build up the dict if you want more than one) | |
indicators = {'NY.GNP.PCAP.CD':'GNI per Capita'} | |
This file contains hidden or 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 enumerações(items): | |
n = len(items) | |
s = [0]*(n+1) | |
k = 0 | |
while True: | |
if s[k] < n: | |
s[k+1] = s[k] + 1 | |
k += 1 | |
else: | |
s[k-1] += 1 |
This file contains hidden or 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 pdfminer.pdfinterp import PDFResourceManager, process_pdf | |
from pdfminer.converter import TextConverter | |
from pdfminer.layout import LAParams | |
from io import StringIO | |
from io import open | |
from urllib.request import urlopen | |
from bs4 import BeautifulSoup | |
import csv |