Flashcard: Python Data Handling and String Formatting — 20 carte

Tutte le carte

1Domanda

Dictionary comparison — method?

Risposta

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

2Domanda

keys() — returns?

Risposta

A view object of all dictionary keys.

3Domanda

dict() — creates?

Risposta

A dictionary from sequences of key-value pairs.

4Domanda

KeyError — when?

Risposta

Accessing a non-existent dictionary key.

5Domanda

String format() — purpose?

Risposta

Insert variables into strings dynamically.

6Domanda

!r and !s — in format?

Risposta

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

7Domanda

String repetition — operator?

Risposta

The `*` operator repeats strings.

8Domanda

String slicing — syntax?

Risposta

[start:stop:step] to extract substrings.

9Domanda

count() — does?

Risposta

Counts occurrences of a substring in a string.

10Domanda

replace() — does?

Risposta

Replaces substrings within a string.

11Domanda

open() — mode?

Risposta

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

12Domanda

read(n) — reads?

Risposta

n characters from an open file.

13Domanda

readline() — reads?

Risposta

A single line from a file.

14Domanda

try-except-else — purpose?

Risposta

Handle exceptions during file operations.

15Domanda

Python file modes?

Risposta

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

16Domanda

Python data types?

Risposta

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

17Domanda

Mutable data structure?

Risposta

List and dict are mutable; tuple is immutable.

18Domanda

Set — characteristics?

Risposta

Unordered, unique elements, supports set operations.

19Domanda

Variables — rules?

Risposta

Start with letter/underscore, case-sensitive.

20Domanda

Functions — define with?

Risposta

Using `def` keyword, reusable code blocks.

Metti alla prova te stesso con il quiz

Metti alla prova le tue conoscenze con 10 domande su 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?

Fai il quiz →

Leggi la scheda di revisione

Ripassa il corso completo nella scheda di revisione per Python Data Handling and String Formatting.

Vedi la scheda di revisione →

Similar courses

Crea le tue flashcard

Importa il tuo corso e l'AI genera flashcard in 30 secondi.

Generatore di flashcard