🌍 Python Programming · flashcards
Python Programming Python Fundamentals Flashcards
50 question-and-answer cards covering Python Fundamentals as it is examined in Python Programming. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.
24 sample cards from the Python Fundamentals deck
Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.
Which values does bool() consider falsy in Python?
Falsy values include: 0, 0.0, empty string "", empty collections ([], {}, (), set()), None, and False. All other values are truthy.
What are keywords (reserved words) in Python, and can they be used as variable names?
Keywords are reserved words with special meaning in the language (e.g., if, for, while, def, class, return, True, None). They cannot be used as identifiers/variable names.
How can you view the full list of Python keywords programmatically?
Import the keyword module and print keyword.kwlist, or use help("keywords") in the interpreter.
List the seven arithmetic operators in Python.
Addition +, subtraction -, multiplication *, division /, floor division //, modulo %, and exponentiation **.
What does the ** operator compute, and what is the value of $2 ** 10$?
The ** operator raises a number to a power (exponentiation). $2 ** 10 = 1024$.
Name the six comparison (relational) operators in Python.
Equal to ==, not equal to !=, greater than >, less than <, greater than or equal to >=, and less than or equal to <=.
What are the three logical operators in Python and what do they do?
and (True only if both operands are true), or (True if at least one is true), and not (inverts the Boolean value).
What does 'short-circuit evaluation' mean for and / or?
Python stops evaluating a logical expression as soon as the result is determined: for and, if the first operand is falsy it returns it immediately; for or, if the first operand is truthy it returns it immediately, skipping the second operand.
What is the difference between = and == in Python?
= is the assignment operator that binds a value to a variable. == is the comparison operator that tests whether two values are equal, returning a Boolean.
What is an augmented assignment operator? Give three examples and their meaning.
It combines an operation with assignment. x += 3 means x = x + 3; x *= 2 means x = x * 2; x //= 4 means x = x // 4. Others include -=, /=, %=, **=.
What is the value of x after: x = 10; x -= 4; x **= 2?
x starts at 10, becomes 6 after x -= 4, then becomes 36 after x **= 2 (since $6^{2} = 36$).
Name the six bitwise operators in Python.
AND &, OR |, XOR ^, NOT ~, left shift <<, and right shift >>.
What does the left-shift operator do, and what is $3 << 2$?
It shifts the bits of a number left by n positions, equivalent to multiplying by $2^{n}$. $3 << 2 = 3 \times 2^{2} = 12$.
What does the bitwise AND of $5 \, \& \, 3$ evaluate to, and why?
It equals 1. In binary $5 = 101$ and $3 = 011$; ANDing bit by bit gives $001 = 1$ (only bits set in both are kept).
What is operator precedence, and where does exponentiation ** rank relative to multiplication and addition?
Precedence determines the order operators are evaluated. Exponentiation ** has higher precedence than multiplication/division, which in turn are higher than addition/subtraction. So $2 + 3 * 4 = 14$ and $2 * 3 ** 2 = 18$.
What is operator associativity, and how does the ** operator associate?
Associativity decides grouping when operators share the same precedence. Most operators are left-associative, but ** is right-associative: $2 ** 3 ** 2 = 2 ** (3 ** 2) = 2^{9} = 512$.
How do you override the default operator precedence in an expression?
Use parentheses (). Expressions inside parentheses are always evaluated first, e.g., $(2 + 3) * 4 = 20$ instead of $2 + 3 * 4 = 14$.
What does the input() function do, and what type does it always return?
input() reads a line of text typed by the user from standard input and returns it as a string (str), even if the user types digits.
How do you read an integer from the user using input()?
Wrap input() in int(), e.g., age = int(input("Enter age: ")). The string returned by input() must be cast to int (or float) for numeric use.
What is an f-string, and how is it written?
An f-string (formatted string literal) is prefixed with f and lets you embed expressions inside curly braces {} directly in a string. Example: name = "Sam"; f"Hello, {name}!" produces "Hello, Sam!".
Name three ways to format strings in Python.
1) f-strings: f"{x}". 2) The str.format() method: "{}".format(x). 3) The older %-formatting: "%d" % x. F-strings (Python 3.6+) are the modern, preferred approach.
What do the escape sequences \n and \t represent?
\n represents a newline (moves to the next line), and \t represents a horizontal tab. Both are backslash escape sequences interpreted within strings.
How do you include a literal backslash or a literal double quote inside a double-quoted string?
Use \\ for a literal backslash and \" for a literal double quote. A raw string prefixed with r (e.g., r"C:\path") also treats backslashes literally.
Write the general structure of a Python if / elif / else conditional statement.
if condition1:\n block1\nelif condition2:\n block2\nelse:\n block3\nEach clause ends with a colon, and the associated block is indented (conventionally 4 spaces). elif and else are optional.
What this deck covers
The Python Fundamentals deck follows the Python Programming Python Fundamentals syllabus — 5 chapters and 22 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 10.0 cards per chapter.
Answers are written to be recallable, not just readable — averaging about 142 characters, which is long enough to carry the reasoning and short enough to say out loud.
A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.
Python Fundamentals flashcards FAQ
How many Python Fundamentals flashcards are in this Python Programming deck?
50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.
Are these Python Programming flashcards free?
Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.
What do the Python Fundamentals cards cover?
They follow the Python Programming Python Fundamentals syllabus — 5 chapters and 22 topics — so the questions track what is actually examinable.
How should I use these flashcards?
Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.