Programming Concepts Flashcards
What is an algorithm?
A step-by-step set of instructions used to solve a problem or perform a task.
What is a variable?
A named storage location that holds a value which can change while the program is running.
What is a constant?
A named value that does not change while the program is running.
What is sequence in programming?
The order in which instructions are executed, one after another.
What is selection in programming?
Making decisions in code using conditions (e.g., if, elif, else).
What is iteration in programming?
Repeating a set of instructions — can be a fixed number of times (for) or while a condition is true (while).
What is a data type?
A classification of data which tells the computer how the programmer intends to use it (e.g., integer, string, boolean).
What are the common data types in Python?
• Integer (int): whole numbers
• Float: numbers with decimal places
• String (str): text
• Boolean (bool): True or False
What is casting in programming?
Changing the data type of a value (e.g., int(“10”) to turn a string into an integer).
What are the comparison operators in Python?
• == (equal to)
• != (not equal to)
• < (less than)
• > (greater than)
• <= (less than or equal to)
• >= (greater than or equal to)
What are logical operators in Python?
• and: True if both conditions are true
• or: True if at least one condition is true
• not: Reverses the condition (True becomes False)
What is a subroutine?
A block of code that can be called and reused — either a function or a procedure.
What is the difference between a function and a procedure?
• Function: returns a value
• Procedure: performs an action but doesn’t return a value
What are the advantages of using subroutines?
• Avoids repetition
• Makes code easier to read and test
• Allows code reuse
• Makes programs easier to maintain
What is the purpose of comments in code?
To explain what the code does — useful for documentation and understanding by others (and yourself).
What is a syntax error?
An error in the code that breaks the rules of the programming language — prevents the program from running.
What is a logic error?
An error in the program’s design that causes incorrect behaviour or output, even though the code runs.
What is debugging?
The process of finding and fixing errors (bugs) in a program.
What is an IDE?
Integrated Development Environment — a software package that provides tools for coding, such as a code editor, debugger, and interpreter/compiler.
Name three features of an IDE that help programmers.
• Syntax highlighting
• Error messages and debugging tools
• Code completion and suggestions