Programming Fundamentals and Control Flow
Core building blocks of programs
From instructions to behavior
A program is a sequence of instructions executed by a machine. Variables store values, expressions compute new values, and control flow determines which instructions run and how often. Together, these ideas let you transform input into output in a repeatable way.
Essential programming concepts
A problem-solving workflow
-
1
Step 1: Identify inputs, outputs, and constraints.
-
2
Step 2: Break the problem into smaller subproblems.
-
3
Step 3: Write the algorithm in plain language or pseudocode.
-
4
Step 4: Implement the solution in code.
-
5
Step 5: Test with normal, edge, and invalid cases.
Which structure is best for repeating a task until a condition becomes false?
Loops repeat code based on a condition or fixed count.
Correct answer: Loop
Why are functions useful in programming?
Functions support modular design and abstraction.
Correct answer: They help organize code, avoid repetition, and make programs easier to test and reuse.
Pseudocode thinking
Pseudocode is a human-readable description of an algorithm. It helps separate the logic of a solution from the syntax of any specific language, which makes it easier to reason about correctness before coding.
What is an edge case?
Edge cases often reveal assumptions or hidden bugs.
Correct answer: A case at the boundary of expected behavior
Describe one good test case for a function that finds the maximum of a list.
Strong tests include typical and boundary cases.
Correct answer: Test a list with positive numbers, a list with negative numbers, and a single-element list.