<jupyter_start><jupyter_text>operaçõesvamos fazer operações<jupyter_code>h = 'hello'
w = 'world'
h + w
a + c
str(a) + h
int(c)
int(1.9)
c + a
h.upper()
h.capitalize()<jupyter_output><empty_output><jupyter_text>* objetos mutaveis: list, set, dict* objetos imutaveis: bool, int, float, tuple, str,...<jupyter_code>def funcao_que_nao_altera_argumento(a):
    a = 100

b = 10
funcao_que_nao_altera_argumento(b)
print(b)
def funcao_que_altera_argumento(a):
    b = a
    b[1] = 10
    
b = [1,2,3,4,5]
funcao_que_altera_argumento(b)
print(b)
a = 10
id(a)
b = 10
id(b)
a = 20
id(a)<jupyter_output><empty_output><jupyter_text>listas, conjuntos, dicionarios<jupyter_code>l = [1, 2, 3, 4, 5]
l.append(20)
l
l[0]
l[-1]
l[-2]
l[1:4]
l[1:-1]
l[50]
l[40:50]
s = {1,2,3,4,5,5,4,4,3}
s
list(s)
set(l)
l.append('a')
l
l[::3]
l[::-1]
l + l
set(l[::-1] + l)<jupyter_output><empty_output><jupyter_text>dicionário<jupyter_code>d = {'a': 1, 'b': 2, 'c': 3}
d = {'c': 3, 'b': 2, 'a': 1,}
d = dict(a = 1, b = 2)
d
d['a']
d['w'] = 50
d
d.keys()
d.values()
d.items()
type(d)
type(s)
type(l)
x = 10
y = 20
z = 30
d2 = dict(x = x, y = y, z = z)
d2
d['xyz'] = d2
from pprint import pprint
pprint(d)
d['xyz']
d.keys()
d['m']
d.get('m', -1)<jupyter_output><empty_output><jupyter_text>tuple<jupyter_code>t = (1,2,3)
t[2]
t[1:30]
t.append(30)
t = (1,2,3,4)
s_vazio = set()
d_vazio = dict()
l_vazia = list()
d_vazio_nao_fazer = {}
l_vazia_nao_fazer = []
type(d_vazio_nao_fazer)<jupyter_output><empty_output><jupyter_text>loops<jupyter_code>lista_para_varredura = [0,1,2,3,4,5,6,7,8,9]

for i in lista_para_varredura[6:2:-1]:
    print(i)
lista_para_varredura = range(10)

for i in lista_para_varredura[1:5]:
    print(i)
for i in range(5, 10):
    print(i)
d
for i in s:
    print(i)
i = iter(d)
next(i)
next(i)
next(i)
next(i)
next(i)<jupyter_output><empty_output><jupyter_text>condições<jupyter_code>multiplos = list()

for i in range(20):
    if i % 3 == 0:
        multiplos.append(i)
    else:
        multiplos.append("n")
        
print(multiplos)<jupyter_output>[0, 'n', 'n', 3, 'n', 'n', 6, 'n', 'n', 9, 'n', 'n', 12, 'n', 'n', 15, 'n', 'n', 18, 'n']<jupyter_text>list comprehension<jupyter_code>print([i if i%3 == 0 else 'n' for i in range(20)])
[i for i in range(20) if i % 3 == 0]
[i if i % 3 == 0 else 'n' for i in range(20)]
b = True
a = 5 if b else 10
if b == True:
    a = 5
else:
    a = 10<jupyter_output><empty_output><jupyter_text>exercicio I<jupyter_code>[1,4,9,16,25]
[-1,2,-1,6,-1,10,-1,14,-1,18,-1]
[[1,0,0], [0,1,0], [0,0,1]]
[[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]]<jupyter_output><empty_output><jupyter_text>Exercicio II<jupyter_code>import numpy as np
import pandas as pd
materia = ['EXECUÇÃO'] * 91 + ['BUSCA E APREENSÃO'] * 26 + \
          ['REINTEGRAÇÃO DE POSSE'] * 5
materia = list(np.random.choice(materia, size = len(materia), replace = False))
materia_series = list(materia)
pd.Series(materia_series).value_counts()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20792414493735184, 'fraction_numerical': 0.06400270910938029, 'mean_word_length': 5.004065040650406, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '125496', 'license': 'MIT', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1511, 'n_words': 302, 'path': 'Jupyter Tests/Aula 1.ipynb', 'repo_name': 'ricardoslee/Trabalhos', 'size': '2953'}