1/83
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is a computer program?
A list of instructions that directs the computer on its operations.
What is programming, and who is a programmer?
Programming is the act of developing a computer program; a programmer is the person who develops it.
What are the six steps in program planning and development, in order?
Problem Analysis, Setting up the Algorithm, Coding, Encoding, Running/Testing/Debugging, Documentation.
What is done in the Problem Analysis step?
Define and understand the problem by analyzing its requirements, constraints, and objectives.
What is done in the Setting up the Algorithm step?
Design a step-by-step plan by breaking the problem into smaller tasks and deciding the logical flow of operations.
What is the difference between Coding and Encoding in program development?
Coding is translating the algorithm into actual Python code; encoding is saving that code into a file with the proper extension (usually .py).
What does Testing involve in program development?
Providing different inputs to the program and verifying that the outputs match expectations.
What does Documentation include?
Comments within the code, a comprehensive description of how the program works, and usage examples.
What is an algorithm?
A process that performs a sequence of operations in order to solve a given problem.
Why is an algorithm needed before writing a program?
Writing a large or good program directly is very difficult; an algorithm serves as the design, just as a building needs a design before construction.
What key idea defines how an algorithm behaves with inputs and outputs?
Given the same input, an algorithm always produces the same output.
What does the "Unambiguous" characteristic of an algorithm require?
Each step and its inputs/outputs must be clear and lead to only one meaning.
How many inputs and outputs should an algorithm have?
0 or more well-defined inputs and 1 or more well-defined outputs.
What does the "Finiteness" characteristic of an algorithm require?
The algorithm must terminate after a finite number of steps.
What does the "Feasible" characteristic of an algorithm require?
It must be feasible with the available resources.
What does the "Independent" characteristic of an algorithm require?
Its step-by-step directions must be independent of any programming code.
What is a flowchart?
A visual diagram that represents the steps of a process or algorithm using standardized symbols connected by arrows.
What are the benefits of using flowcharts?
They visualize complex processes, plan program logic before coding, identify errors early, and improve understanding of control flow.
Which flowchart symbol is the Terminal, and what is its rule?
An oval or rounded rectangle marking the beginning or end; every flowchart must have at least one Start and one End.
Which flowchart symbol represents a Process/Operation?
A rectangle, used for a processing step, calculation, or assignment (e.g., sum = a + b).
Which flowchart symbol represents a Decision?
A diamond, used for branching logic with outcomes such as Yes/No or True/False.
Which flowchart symbol represents Input/Output?
A parallelogram, used for data entering or leaving the process (e.g., reading a value or displaying a result).
Which flowchart symbol represents Preparation?
A hexagon, used for initialization of values (also called the initialization symbol).
What is the difference between an On-Page Connector and an Off-Page Connector?
An on-page connector (circle) links symbols on the same page; an off-page connector links to another page. Both come in pairs.
What is the purpose of flow lines in a flowchart?
They connect symbols and show the direction of flow.
What are the three basic control structures?
Sequence, Selection, and Repetition.
What defines a Sequence structure?
Instructions execute one after another in the exact order they appear, with no steps skipped and no decisions made.
What defines a Selection structure?
It evaluates a condition and executes different paths depending on whether the condition is true (YES) or false (NO).
What defines a Repetition structure?
A block of steps executes multiple times while a condition is true, continuing until the exit condition is met.
How do real programs use the three control structures?
They combine all three: steps flow in order, branch on conditions, and loop until a goal is reached.
What is tracing an algorithm?
Manually following a flowchart or algorithm step by step while tracking variable values and decision outcomes at each stage.
Why is tracing an algorithm useful?
It detects logic errors before coding, builds understanding of flow, is essential for debugging, and confirms correctness with real data.
What are four best practices for designing flowcharts?
Use connectors for complex flows, keep flow top-to-bottom or left-to-right, label decision branches clearly, and avoid crossing lines.
What is Python?
An interpreted, object-oriented, high-level programming language created by Guido van Rossum and released in 1991.
How does Python indicate a code block?
Through indentation.
What is a variable in Python, and when is it created?
A container for storing data values; it is created the moment you first assign a value to it.
What characters may a Python variable name be composed of?
Upper-case or lower-case letters, digits, and the underscore (_).
What must a Python variable name begin with?
A letter; the underscore counts as a letter.
Are Python variable names case-sensitive?
Yes, upper- and lower-case letters are treated as different.
What words can a Python variable name never be?
Python's reserved words/keywords (e.g., if, else, class, while).
What are the four basic data types shown for Python variables?
String, Integer, Float, and Boolean.
What does the print() function do?
It is a built-in function that outputs a specified message to the screen/console.
What does the end keyword argument of print() do?
It sets what is printed at the end of the output instead of the default newline.
What does the sep keyword argument of print() do?
It sets the separator placed between multiple values being printed.
What do the escape sequences \n, \t, \, and \' produce?
\n is a newline, \t is a tab, \ inserts a backslash, and \' inserts a single quote.
What does the input() function do?
It accepts the user's input.
What data type does input() return, and why does that matter?
A string, so it must be cast (e.g., with int()) before being used in numeric operations.
What is casting?
Converting one data type into another.
What do the casting functions int() and str() do?
int() converts a value to an integer; str() converts a value to a string.
What is the difference between the / operator and the // operator?
/ returns the quotient (division); // is floor division, which returns the quotient rounded down to the next smallest whole number.
What does the % operator do?
Modulus: divides the left operand by the right and returns the remainder.
What does the ** operator do?
Exponentiation: raises the left value to the power of the right value.
What is the order of Python operator precedence from highest to lowest?
** first, then unary ~x +x -x, then * / % //, then + -, then comparisons (== !=
What is a string?
A series of characters interpreted as text.
Why must a number be converted with str() when joined to text using +?
The + operator for concatenation only joins strings, so a number must be cast to a string first.
How can you write a string spanning multiple lines?
Enclose it in three double quotes or three single quotes.
What are the three ways to use string placeholders?
The {} with .format(), the % operator, and f-strings (F or f).
What is the difference between {} placeholders with and without numbers?
Empty {} fill in order; numbered placeholders like {0} and {1} fill by the position of the argument given to .format().
What do the placeholders %s and %.2f represent?
%s is a string placeholder; %.2f is a float formatted to two decimal places.
How do you write an f-string?
Put an f before the opening quote and place variable names inside curly braces, e.g., f"Cost {cost}".
What do upper(), lower(), capitalize(), and title() do?
They convert a string to uppercase, to lowercase, the first character to uppercase, and the first character of each word to uppercase, respectively.
What do split(), replace(), and len() do?
split() splits a string at a separator and returns a list; replace() swaps a specified value for another; len() counts the characters in a string.
What are conditional statements also known as, and what do they do?
Decision-making statements; they execute a block of code depending on whether a given condition is true or false.
What are the four decision-making statements in Python?
if, if-else, if-elif-else, and nested if/if-else statements.
What are Python's six relational operators?
== (equal to), != (not equal to), < (less than),
What is the difference between = and == in Python?
= assigns a value to a variable; == compares two values for equality.
What does the not operator do?
It reverses a Boolean value: True becomes False and False becomes True.
When does the and operator return True?
Only when both conditions are True.
When does the or operator return False?
Only when both conditions are False.
What is the precedence order of the logical operators?
not is highest, then and, then or.
What does an if statement consist of?
A Boolean expression (the condition) ending in a colon, followed by indented statements that run only if the condition is True.
Which values does Python treat as TRUE and which as FALSE in a condition?
Non-zero and non-null values are TRUE; zero or null is FALSE.
What are the rules for the colon and indentation in an if statement?
The colon is required and separates the header from the body; the body must be indented, with four spaces as the standard.
Why must indentation be consistent within a block?
Python has no braces, so blocks are defined by line indentation, which is rigidly enforced, and Python 3 does not allow mixing tabs and spaces.
What happens to the indented statements if the if condition is False?
They are skipped, and execution continues with the next instruction at the original indentation level.
What does an else statement do?
It holds the code that runs when the if condition evaluates to False.
What does elif do, and how is it different from else?
elif checks additional conditions and stops at the first one that is true; there can be many elif statements but at most one else.
What is a cascade of if-elif-else statements?
A series of if, elif, and else branches checked in order, where only the first true branch is executed.
What are the rules for using else in a cascade?
else cannot be used without a preceding if, it is optional, and it must be the last branch.
What happens in a cascade if there is no else branch and no condition is true?
None of the branches is executed.
What is nesting in if statements?
Placing one if or if-else statement inside another.
How do you determine which if an else belongs to in nested statements?
Each else pairs with the if at the same indentation level.
What are suites in Python?
Groups of individual statements that make a single code block; compound statements such as if, while, def, and class require a header line and a suite.
What is the purpose of the pass statement?
It is a placeholder for an if statement (or other block) with no content, avoiding an error because such blocks cannot be empty.