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
foo = 'bar' |
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
"""Função que conta os caracteres de uma string | |
Ex: | |
>>> contar_caracteres('renzo') | |
e:1 | |
n:1 | |
o:1 | |
r:1 | |
z: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
""" | |
>>> tv = Televisao(1,0) | |
>>> tv.canal | |
1 | |
>>> tv.volume | |
0 | |
>>> tv.mudar_canal(5) | |
5 | |
>>> tv.mudar_canal(11) | |
'Canal fora do range 1 a 10' |
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 flask.cli import AppGroup | |
user_cli = AppGroup('users', help='Manage users') | |
@user_cli.command('create_admin', help='Create a user with Admin role on database') | |
@click.option('--name', prompt='User name') | |
@click.option('--email', prompt='User email') | |
@click.option('--password', prompt='User password', hide_input='True', confirmation_prompt=True) | |
def create_admin(name, email, password): | |
... |
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 chain | |
def string_n_string(s, n): | |
for _ in range(n): | |
even = (char for i, char in enumerate(s) if i % 2 == 0) | |
odd = (char for i, char in enumerate(s) if i % 2 != 0) | |
s = ''.join(chain(even , odd)) | |
return s |
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 fat(n): | |
i = 1 | |
result = 1 | |
def fat_iter(): | |
nonlocal i, result | |
if i > n: | |
return | |
result *= i | |
i += 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
def fat(n): | |
def fat_iter(i, result): | |
if i > n: | |
return result | |
return fat_iter(i + 1, result * i) | |
return fat_iter(1, 1) | |
def test(): |
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 zip_longest | |
def sum_prod(iter, iter2): | |
return sum(map(lambda tpl: tpl[0] * tpl[1], zip_longest(iter, iter2, fillvalue=1))) | |
def test_sum_prod(): | |
assert 0 == sum_prod([], []) | |
assert 2 == sum_prod([2], []) |
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
import datetime | |
data = [ | |
{ | |
'C01_tipo_de_registro': 1, 'C02_numero_de_negocios_por_codigo_de_negociacao': 10, | |
'C03_natureza_da_operacao': 'C', 'C04_codigo_de_negociacao': 'AAAA3', | |
'C05_tipo_de_mercado': 'VIS', 'C06_tipo_da_transacao': 'NOR', | |
'C07_nome_da_sociedade_emissora': 'Aa Aa Aa', 'C08_especificacao': 'ON NM', | |
'C09_quantidade_do_negocio': 100, 'C10_1_preco_do_negocio': 3.5, | |
'C11_codigo_do_usuario_contraparte': 999, 'C12_prazo_de_vencimento': '', |
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
with open('seu_arquivo.txt', 'r', encoding='utf-8') as file: | |
new_line=[] | |
for line in file: | |
new_line.append(line) | |
if not # Aqui vai sua condiçao para concatenar com a(s) outra(s) linha(s): | |
print(''.join(new_line)) | |
new_line=[] | |
if new_line: | |
print(''.join(new_line)) |