Flashcards: Python Data Handling and String Formatting — 20 cartões

Todos os cartões

1Pergunta

Dictionary comparison — method?

Resposta

Use `==` for equality; `cmp()` in Python 2.

2Pergunta

keys() — returns?

Resposta

A view object of all dictionary keys.

3Pergunta

dict() — creates?

Resposta

A dictionary from sequences of key-value pairs.

4Pergunta

KeyError — when?

Resposta

Accessing a non-existent dictionary key.

5Pergunta

String format() — purpose?

Resposta

Insert variables into strings dynamically.

6Pergunta

!r and !s — in format?

Resposta

Control object representation: repr() vs str().

7Pergunta

String repetition — operator?

Resposta

The `*` operator repeats strings.

8Pergunta

String slicing — syntax?

Resposta

[start:stop:step] to extract substrings.

9Pergunta

count() — does?

Resposta

Counts occurrences of a substring in a string.

10Pergunta

replace() — does?

Resposta

Replaces substrings within a string.

11Pergunta

open() — mode?

Resposta

Specifies file access: 'r', 'w', etc.

12Pergunta

read(n) — reads?

Resposta

n characters from an open file.

13Pergunta

readline() — reads?

Resposta

A single line from a file.

14Pergunta

try-except-else — purpose?

Resposta

Handle exceptions during file operations.

15Pergunta

Python file modes?

Resposta

'r' for read, 'w' for write, 'b' for binary.

16Pergunta

Python data types?

Resposta

Int, float, string, list, tuple, dict.

17Pergunta

Mutable data structure?

Resposta

List and dict are mutable; tuple is immutable.

18Pergunta

Set — characteristics?

Resposta

Unordered, unique elements, supports set operations.

19Pergunta

Variables — rules?

Resposta

Start with letter/underscore, case-sensitive.

20Pergunta

Functions — define with?

Resposta

Using `def` keyword, reusable code blocks.

Teste-se com o quiz

Teste seu conhecimento com 10 perguntas sobre Python Data Handling and String Formatting.

1. How do you create a Python dictionary from a list of key-value pair tuples?

2. What is the purpose of the 'cmp()' function in Python 2 when used with dictionaries?

Faça o quiz →

Leia a ficha de revisão

Revise o curso completo na ficha de revisão para Python Data Handling and String Formatting.

Veja a ficha de revisão →

Similar courses

Crie seus próprios flashcards

Importe seu curso e a IA gera flashcards em 30 segundos.

Gerador de flashcards