Problem Solving and Programming 1 Flashcards
What is a variable in programming?
A variable is a container that holds a value or data that can be changed during program execution.
What is the difference between an integer and a float?
An integer is a whole number, while a float is a number that includes a decimal point.
What is the purpose of the “if” statement in programming?
An “if” statement allows you to execute certain code only if a specified condition is true.
What is a loop in programming?
A loop is a programming construct that repeats a block of code multiple times based on a condition.
What is the difference between a “for” loop and a “while” loop?
A “for” loop repeats a block of code a set number of times, while a “while” loop repeats as long as a given condition is true.
What is an algorithm in computer science?
An algorithm is a step-by-step procedure for solving a problem or performing a task.
What is the purpose of a function in programming?
A function is a reusable block of code that performs a specific task, making the program more modular and easier to maintain.
What is a parameter in a function?
A parameter is a variable in a function definition that receives a value when the function is called.
What is a return value in a function?
A return value is the result that a function gives back after performing its task, often used to send data back to the calling code.
What is debugging?
Debugging is the process of identifying and fixing errors or bugs in the code to ensure the program runs as expected.
What is a syntax error?
A syntax error occurs when the code violates the rules of the programming language, such as missing parentheses or a misplaced semicolon.
What is a logical error in programming?
A logical error happens when the code runs without crashing but produces incorrect results due to a flaw in the logic.
What is a “while” loop used for?
A “while” loop is used to repeat a block of code as long as a specified condition remains true.
What is a list in programming?
A list is an ordered collection of items, which can be of different data types, and is often used to store multiple values.
How do you access an item in a list in Python?
You access an item in a list using its index, starting from 0.
Example: my_list[0] accesses the first item.