Karteikarten: Python Data Handling and String Formatting — 20 Karten

Alle Karten

1Frage

Dictionary comparison — method?

Antwort

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

2Frage

keys() — returns?

Antwort

A view object of all dictionary keys.

3Frage

dict() — creates?

Antwort

A dictionary from sequences of key-value pairs.

4Frage

KeyError — when?

Antwort

Accessing a non-existent dictionary key.

5Frage

String format() — purpose?

Antwort

Insert variables into strings dynamically.

6Frage

!r and !s — in format?

Antwort

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

7Frage

String repetition — operator?

Antwort

The `*` operator repeats strings.

8Frage

String slicing — syntax?

Antwort

[start:stop:step] to extract substrings.

9Frage

count() — does?

Antwort

Counts occurrences of a substring in a string.

10Frage

replace() — does?

Antwort

Replaces substrings within a string.

11Frage

open() — mode?

Antwort

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

12Frage

read(n) — reads?

Antwort

n characters from an open file.

13Frage

readline() — reads?

Antwort

A single line from a file.

14Frage

try-except-else — purpose?

Antwort

Handle exceptions during file operations.

15Frage

Python file modes?

Antwort

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

16Frage

Python data types?

Antwort

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

17Frage

Mutable data structure?

Antwort

List and dict are mutable; tuple is immutable.

18Frage

Set — characteristics?

Antwort

Unordered, unique elements, supports set operations.

19Frage

Variables — rules?

Antwort

Start with letter/underscore, case-sensitive.

20Frage

Functions — define with?

Antwort

Using `def` keyword, reusable code blocks.

Teste dich mit dem Quiz

Teste dein Wissen mit 10 Fragen zu 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?

Quiz machen →

Lernzettel lesen

Überprüfe den vollständigen Kurs im Lernzettel zu Python Data Handling and String Formatting.

Lernzettel ansehen →

Similar courses

Erstelle deine eigenen Karteikarten

Importiere deinen Kurs und die KI erstellt in 30 Sekunden Karteikarten.

Karteikarten-Generator