Estruturas de Dados em Python

RaptJudgment1138 avatar
RaptJudgment1138
·
·
Download

Start Quiz

Study Flashcards

8 Questions

Em Python, as listas são coleções ordenadas e imutáveis de itens.

False

Os dicionários em Python são coleções ordenadas de pares chave-valor.

False

Os conjuntos em Python são coleções ordenadas e mutáveis de itens.

False

A operação de indexação é utilizada para acessar um elemento em uma lista.

True

O método append é utilizado para remover um elemento de uma lista.

False

A operação de união de conjuntos é utilizada para encontrar os elementos comuns entre dois conjuntos.

False

Os tuples em Python são coleções ordenadas e mutáveis de itens.

False

A operação de slicing é utilizada para acessar um elemento em uma lista.

False

Study Notes

Data Structures in Python

Lists

  • Ordered collection of items
  • Indexable (access elements using an index)
  • Mutable (can be modified)
  • Dynamic size (can grow or shrink)
  • Example: my_list = [1, 2, 3, 4, 5]

Tuples

  • Ordered, immutable collection of items
  • Indexable (access elements using an index)
  • Example: my_tuple = (1, 2, 3, 4, 5)

Dictionaries

  • Unordered collection of key-value pairs
  • Mutable (can be modified)
  • Example: my_dict = {'name': 'John', 'age': 30}

Sets

  • Unordered collection of unique items
  • Mutable (can be modified)
  • Example: my_set = {1, 2, 3, 4, 5}

Operations on Data Structures

  • Indexing: access an element at a specific index (e.g. my_list[0])
  • Slicing: access a subset of elements (e.g. my_list[1:3])
  • Append: add an element to the end of a list (e.g. my_list.append(6))
  • Insert: add an element at a specific position in a list (e.g. my_list.insert(2, 7))
  • Remove: remove the first occurrence of an element in a list (e.g. my_list.remove(3))
  • Sort: sort a list in ascending or descending order (e.g. my_list.sort() or my_list.sort(reverse=True))
  • Union: combine two sets (e.g. my_set1.union(my_set2))
  • Intersection: find the common elements between two sets (e.g. my_set1.intersection(my_set2))

Estruturas de Dados em Python

Listas

  • Coleção ordenada de itens
  • Indexável (acessar elementos usando um índice)
  • Mutável (pode ser modificado)
  • Tamanho dinâmico (pode crescer ou diminuir)
  • Exemplo: my_list = [1, 2, 3, 4, 5]

Tuplas

  • Coleção ordenada e imutável de itens
  • Indexável (acessar elementos usando um índice)
  • Exemplo: my_tuple = (1, 2, 3, 4, 5)

Dicionários

  • Coleção desordenada de pares chave-valor
  • Mutável (pode ser modificado)
  • Exemplo: my_dict = {'name': 'John', 'age': 30}

Conjuntos

  • Coleção desordenada de itens únicos
  • Mutável (pode ser modificado)
  • Exemplo: my_set = {1, 2, 3, 4, 5}

Operações em Estruturas de Dados

  • Indexação: acessar um elemento em uma posição específica (e.g.my_list[0])
  • Fatiamento: acessar um subconjunto de elementos (e.g.my_list[1:3])
  • Anexar: adicionar um elemento ao final de uma lista (e.g.my_list.append(6))
  • Inserir: adicionar um elemento em uma posição específica em uma lista (e.g.my_list.insert(2, 7))
  • Remover: remover a primeira ocorrência de um elemento em uma lista (e.g.my_list.remove(3))
  • Ordenar: ordenar uma lista em ordem ascendente ou descendente (e.g.my_list.sort() ou my_list.sort(reverse=True))
  • União: combinar dois conjuntos (e.g.my_set1.union(my_set2))
  • Intersecção: encontrar os elementos comuns entre dois conjuntos (e.g.my_set1.intersection(my_set2))

Aprenda sobre as diferentes estruturas de dados em Python, incluindo listas, tuplas e dicionários. Entenda como utilizar essas estruturas para armazenar e manipular dados.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Python Data Structure Quiz
3 questions

Python Data Structure Quiz

ConsummateDiscernment avatar
ConsummateDiscernment
Python Single-Dimensional List Access
9 questions
Python Data Structures Exploration
12 questions
Data Structures in Python
9 questions
Use Quizgecko on...
Browser
Browser