Python Basics Flashcards
6 cards from real HACKERRANK practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Python Basics flashcards as text
What is a variable in programming?
Answer: A named storage location for data that can change during program execution
Variables are named containers that store data values in memory, and their contents can be modified during program execution.
What is the time complexity of binary search?
Answer: O(log n)
Binary search has O(log n) complexity because it halves the search space with each comparison, efficiently finding elements in sorted arrays.
What is a list in Python?
Answer: An ordered, mutable collection of elements
A Python list is an ordered, mutable sequence that can hold elements of different types, defined with square brackets.
What is a function in programming?
Answer: A reusable block of code that performs a specific task
Functions encapsulate a specific task into a reusable block of code that can be called with different inputs, promoting code reuse and organization.
What is the difference between '==' and '=' in most programming languages?
Answer: '==' compares values; '=' assigns a value
'=' is the assignment operator (sets a variable's value), while '==' is the comparison operator (checks if two values are equal).
What is a loop used for in programming?
Answer: To repeat a block of code multiple times
Loops execute a block of code repeatedly until a condition is met, avoiding the need to write the same code multiple times.