Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
Every program you'll ever write—from a simple calculator to a complex web application—relies on the same core building blocks. When you're tested on programming fundamentals, you're not just being asked to recall syntax; you're being evaluated on whether you understand how data flows through a program, how decisions get made, and how repetition creates efficiency. These concepts form the foundation for everything from algorithm design to software architecture.
Think of these functions as your programming vocabulary. Variables store your data, control structures direct traffic, and functions package logic for reuse. Master the underlying principles—not just the code snippets—and you'll be able to apply them in any language or context. Don't just memorize what each function does; know why you'd choose one approach over another and when each tool is the right fit.
Programs need somewhere to keep information while they work. The way you store data determines what operations you can perform on it and how efficiently your program runs.
score = 0 becoming score = 100"5" (string) + 5 (integer) fails in strongly-typed languages because the computer sees text and numbers differentlygrades[0] for the first item0, not 1, which is a common source of off-by-one errors"hello"[0:2] returns "he"), concatenate them ("hello" + "world"), or search within them.length(), .toUpperCase(), .split(), and .replace()—these transform text without changing the originalCompare: Arrays vs. Lists—both store collections, but arrays offer faster access with fixed memory allocation while lists provide flexibility at the cost of some performance. If an exam asks about choosing data structures, consider whether your data size is known upfront.
Programs are useless if they can't communicate with users or other systems. I/O operations bridge the gap between your code and the outside world.
input() in Python or Scanner in Java pause execution and wait for user responseprint(), console.log(), or System.out.println() send data to the screen or console"r" for reading, "w" for writing (overwrites!), "a" for appending; using the wrong mode can destroy dataCompare: Console I/O vs. File I/O—both move data in and out of your program, but console operations are temporary and interactive while file operations persist data permanently. FRQs often ask you to modify programs to save results—know how to switch between them.
Programs need to make choices and respond to different conditions. Control structures determine which code runs and when, giving your programs intelligence.
if statements create decision points—code inside the block only executes when the condition evaluates to trueelse and else if handle alternatives—chain multiple conditions to cover all possible scenarios: if this, else if that, else default$$x > 5$$, $$y == 10$$, or $$z != 0$$ return true or false to trigger branchesfor loops iterate a known number of times—use when you know exactly how many repetitions: for i in range(10) runs exactly 10 timeswhile loops continue until a condition fails—use when repetition depends on changing state: keep asking for input until it's validwhile(true) runs foreverCompare: for vs. while loops—both repeat code, but for loops excel when you know the iteration count upfront (traversing an array), while while loops handle uncertain conditions (waiting for valid input). Choosing the wrong loop type is a common exam trap.
Computers excel at math and manipulation. Understanding operators and their rules ensures your calculations produce correct results.
+ (addition), - (subtraction), * (multiplication), / (division), and % (modulus, which returns the remainder)$$(2 + 3) * 4 = 20$$ vs. $$2 + 3 * 4 = 14$$$$7 / 2$$ might return 3 (integer division) or 3.5 (float division) depending on language and data typesCompare: / vs. % operators—division gives you the quotient, modulus gives you the remainder. Modulus is essential for checking divisibility ($$n \% 2 == 0$$ means even), cycling through arrays, or extracting digits. Both appear frequently in algorithm questions.
Good programmers avoid repeating themselves. Functions and methods package logic into reusable units, making code cleaner and easier to maintain.
def functionName(): or similar syntax, then call anywhere by namedef add(a, b): return a + b takes two inputs and sends back their summyString.upper() calls the upper method on that specific string instance, a key concept in object-oriented programmingtry, handle problems in catch or except without crashing the entire programCompare: Functions vs. Methods—both encapsulate reusable logic, but functions are standalone while methods belong to objects and can access that object's data. Understanding this distinction is crucial for object-oriented programming questions.
| Concept | Best Examples |
|---|---|
| Data Storage | Variables, Arrays, Lists |
| Data Types | Integers, Floats, Strings, Booleans |
| User Interaction | Input operations, Output operations, Console I/O |
| Decision Making | if-else statements, Boolean expressions |
| Repetition | for loops, while loops |
| Calculations | Arithmetic operators, Operator precedence, Modulus |
| Code Reuse | Functions, Methods, Parameters/Return values |
| Data Persistence | File reading, File writing, Open/Close pattern |
| Error Management | Try-catch blocks, Debugging techniques |
Which two concepts both store multiple values, and what's the key difference in how they handle size?
If you need to repeat code but don't know in advance how many times, which loop type should you use and why?
Compare and contrast functions and methods—when would you use each, and how do they relate to object-oriented programming?
A program crashes when a user enters "abc" instead of a number. Which two fundamental concepts would you combine to prevent this crash?
You're writing a program that needs to save high scores between gaming sessions. Which fundamental concept enables this, and what's the standard pattern for implementing it?