<jupyter_start><jupyter_text>Estudando Listas<jupyter_code>x = ["a", "b", "c", "d"]
x[1] = "r"
print(x)
x[2:] = ["s", "t"]
print(x)<jupyter_output>['a', 'r', 's', 't']<jupyter_text>pode-se adicionar elementos usando o sinal "+"<jupyter_code>x = ["a", "b", "c", "d"]
y = x + ["e", "f"]
print(y)<jupyter_output>['a', 'b', 'c', 'd', 'e', 'f']<jupyter_text>deletar elementos<jupyter_code>x = ["a", "b", "c", "d"]
del(x[1])
print(x)<jupyter_output>['a', 'c', 'd']<jupyter_text>deletar elementos faz com que os índices mudem<jupyter_code>areas = ["hallway", 11.25, "kitchen", 18.0,
        "chill zone", 20.0, "bedroom", 10.75,
         "bathroom", 10.50, "poolhouse", 24.5,
         "garage", 15.45]
print(areas)
del(areas[10:12])
print(areas)<jupyter_output>['hallway', 11.25, 'kitchen', 18.0, 'chill zone', 20.0, 'bedroom', 10.75, 'bathroom', 10.5, 'poolhouse', 24.5, 'garage', 15.45]
['hallway', 11.25, 'kitchen', 18.0, 'chill zone', 20.0, 'bedroom', 10.75, 'bathroom', 10.5, 'garage', 15.45]<jupyter_text>quando se faz o slide o índice final não contabiliza, é intervalo aberto. [10:12] são os elementos nos índices 10 e 11<jupyter_code>areas = ["hallway", 11.25, "kitchen", 18.0,
        "chill zone", 20.0, "bedroom", 10.75,
         "bathroom", 10.50, "poolhouse", 24.5,
         "garage", 15.45]
print(areas)
del(areas[-4:-2])
print(areas)<jupyter_output>['hallway', 11.25, 'kitchen', 18.0, 'chill zone', 20.0, 'bedroom', 10.75, 'bathroom', 10.5, 'poolhouse', 24.5, 'garage', 15.45]
['hallway', 11.25, 'kitchen', 18.0, 'chill zone', 20.0, 'bedroom', 10.75, 'bathroom', 10.5, 'garage', 15.45]<jupyter_text>--- Listas são posições na memória, algumas operações tem comportamentos distintos<jupyter_code># Create list areas
areas = [11.25, 18.0, 20.0, 10.75, 9.50]
print("areas inicial:", areas)
# Create areas_copy
areas_copy = areas

# Change areas_copy
areas_copy[0] = 5.0

# Print areas
print("areas:", areas)
print("areas_copy:", areas_copy)<jupyter_output>areas inicial: [11.25, 18.0, 20.0, 10.75, 9.5]
areas: [5.0, 18.0, 20.0, 10.75, 9.5]
areas_copy: [5.0, 18.0, 20.0, 10.75, 9.5]<jupyter_text>Para previnir que a mudança ocorra nas duas variáveis é necessário usar o comando ***list( )*** ou ***[ : ]***<jupyter_code># Create list areas
areas = [11.25, 18.0, 20.0, 10.75, 9.50]
print("areas inicial:", areas)
# Create areas_copy
#areas_copy = list(areas)
areas_copy = areas[:]

# Change areas_copy
areas_copy[0] = 5.0

# Print areas
print("areas:", areas)
print("areas_copy:", areas_copy)<jupyter_output>areas inicial: [11.25, 18.0, 20.0, 10.75, 9.5]
areas: [11.25, 18.0, 20.0, 10.75, 9.5]
areas_copy: [5.0, 18.0, 20.0, 10.75, 9.5]<jupyter_text>Teste<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21761658031088082, 'fraction_numerical': 0.10621761658031088, 'mean_word_length': 5.020044543429844, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '632997', 'license': 'MIT', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1229, 'n_words': 279, 'path': 'Intro do Python - DataCamp.ipynb', 'repo_name': 'd77b/DataCamp_DS_Python', 'size': '2702'}