1/21
Flashcards covering key concepts from Lecture 2 of Programming Essentials: variables, naming conventions, built-in functions, operators, PEMDAS, string operations, loops, conditionals, Boolean algebra, and De Morgan's laws.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What are the five stages of problem solving identified in the lecture?
What is the difference between = and == in Python?
= is the assignment token used to assign a value to a variable, whereas == is the comparison operator used to test equality.
What are three conditions that make a variable name illegal in Python?
What formatting tools are recommended to improve code readability alongside meaningful variable names?
Comments (#) and blank lines.
What quoting styles can be used to enclose strings in Python?
Single quotes (′′), double quotes (""), or three of each (′′′′′′ or """""").
What is the difference between standard division (/) and floor division (//) in Python?
Standard division (/) yields a floating-point result, whereas floor division (//) divides and rounds down to the nearest integer.
In Python PEMDAS evaluation order, what is unique about the exponentiation operator (∗∗)?
While operators at the same precedence level evaluate left-to-right, exponentiation (∗∗) evaluates right-to-left (for example, 2∗∗3∗∗2=2∗∗9=512).
What is the modulus operator (%) and what is its precedence level?
It calculates the remainder when the first integer operand is divided by the second, and it shares the same precedence as multiplication and division.
How does the built-in function int() behave when passed a float such as 3.9999 or −3.999?
It discards the fraction and truncates toward zero without rounding to the closest integer, returning 3 and −3 respectively.
How do the + and ∗ operators behave when applied to strings in Python?
+ performs string concatenation, while ∗ performs string repetition (requiring one string operand and one integer operand).
What data type is returned by Python's built-in input() function?
It always returns a string (str).
What is composition in programming?
The combination of small building blocks—such as variables, expressions, statements, and function calls—into larger program chunks.
In a Python for loop, how is the loop body defined?
The loop body is defined by indentation, which determines exactly which statements are executed within the body.

What programming process does this flowchart depict?
The control flow of a for loop iterating over a sequence.

Which conditional construct is illustrated by this flowchart?
An if−else conditional statement branching between two separate statement blocks.

Which conditional construct is depicted in this flowchart?
Chained conditionals (if−elif−else).
When is the else clause of a for−else loop executed?
It executes when the loop completes all iterations without encountering an early break.
After whom are Boolean values named?
British mathematician George Boole, who first formulated Boolean algebra.
How does short-circuit evaluation operate for Python's or and and logical operators?
For or, if the left expression is True, Python does not evaluate the right operand. For and, if the left expression is False, Python does not evaluate the right operand.
What are the logical opposites of the comparison operators ==, !=$, <,
What are De Morgan's Laws expressed in Python syntax?
Using De Morgan's laws and logical opposites, how can if not ((sword_charge>=0.90) and (shield_energy>=100)): be simplified?
if (sword_charge<0.90) or (shield_energy<100):