Dictionary comparison — method?
Use `==` for equality; `cmp()` in Python 2.
keys() — returns?
A view object of all dictionary keys.
dict() — creates?
A dictionary from sequences of key-value pairs.
KeyError — when?
Accessing a non-existent dictionary key.
String format() — purpose?
Insert variables into strings dynamically.
!r and !s — in format?
Control object representation: repr() vs str().
String repetition — operator?
The `*` operator repeats strings.
String slicing — syntax?
[start:stop:step] to extract substrings.
count() — does?
Counts occurrences of a substring in a string.
replace() — does?
Replaces substrings within a string.
open() — mode?
Specifies file access: 'r', 'w', etc.
read(n) — reads?
n characters from an open file.
readline() — reads?
A single line from a file.
try-except-else — purpose?
Handle exceptions during file operations.
Python file modes?
'r' for read, 'w' for write, 'b' for binary.
Python data types?
Int, float, string, list, tuple, dict.
Mutable data structure?
List and dict are mutable; tuple is immutable.
Set — characteristics?
Unordered, unique elements, supports set operations.
Variables — rules?
Start with letter/underscore, case-sensitive.
Functions — define with?
Using `def` keyword, reusable code blocks.
Answer 10 questions on 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?
Go over the full study guide for Python Data Handling and String Formatting.
Read the study guide →Upload your class notes and Revizly writes your flashcards in about a minute.
Flashcard maker