Flashcards : Python Data Handling and String Formatting — 20 cartes

Toutes les cartes

1Question

Dictionary comparison — method?

Réponse

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

2Question

keys() — returns?

Réponse

A view object of all dictionary keys.

3Question

dict() — creates?

Réponse

A dictionary from sequences of key-value pairs.

4Question

KeyError — when?

Réponse

Accessing a non-existent dictionary key.

5Question

String format() — purpose?

Réponse

Insert variables into strings dynamically.

6Question

!r and !s — in format?

Réponse

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

7Question

String repetition — operator?

Réponse

The `*` operator repeats strings.

8Question

String slicing — syntax?

Réponse

[start:stop:step] to extract substrings.

9Question

count() — does?

Réponse

Counts occurrences of a substring in a string.

10Question

replace() — does?

Réponse

Replaces substrings within a string.

11Question

open() — mode?

Réponse

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

12Question

read(n) — reads?

Réponse

n characters from an open file.

13Question

readline() — reads?

Réponse

A single line from a file.

14Question

try-except-else — purpose?

Réponse

Handle exceptions during file operations.

15Question

Python file modes?

Réponse

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

16Question

Python data types?

Réponse

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

17Question

Mutable data structure?

Réponse

List and dict are mutable; tuple is immutable.

18Question

Set — characteristics?

Réponse

Unordered, unique elements, supports set operations.

19Question

Variables — rules?

Réponse

Start with letter/underscore, case-sensitive.

20Question

Functions — define with?

Réponse

Using `def` keyword, reusable code blocks.

Testez-vous avec le QCM

Testez vos connaissances avec un QCM de 10 questions sur 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?

Faire le QCM →

Consultez la fiche

Révisez le cours complet dans la fiche de révision de Python Data Handling and String Formatting.

Voir la fiche →

Cours similaires

Crée tes propres flashcards

Importe ton cours et l'IA génère des flashcards en 30 secondes.

Générateur de flashcards