Unlock hundreds more features
Save your Quiz to the Dashboard
View and Export Results
Use AI to Create Quizzes and Analyse Results

Sign inSign in with Facebook
Sign inSign in with Google

Take the Programming Fundamentals Assessment Quiz

Sharpen Your Core Programming Basics Skills

Difficulty: Moderate
Questions: 20
Learning OutcomesStudy Material
Colorful paper art depicting elements related to Programming Fundamentals Assessment Quiz.

Ready to assess your coding knowledge? This Programming Fundamentals Assessment Quiz offers 15 multiple-choice questions covering variables, loops, functions, and logic. It's perfect for students, self-learners, and educators looking to evaluate and reinforce core programming concepts. Detailed feedback after each question helps solidify your understanding and boost confidence. Feel free to tweak any question in our quizzes editor or dive into similar challenges like the Programming Fundamentals Quiz and the Java Programming Fundamentals Quiz.

What is the result of evaluating the expression 3 + 4 in most programming languages?
7
34
5
"7"
The + operator performs arithmetic addition on numeric literals. Adding 3 and 4 yields the numeric result 7.
Which of the following is a valid variable name in Python?
var-name
2var
var name
var_name
In Python, variable names cannot start with a digit or contain spaces or hyphens. Underscores are allowed and commonly used.
What data type does the boolean literal True represent in many programming languages?
String
Integer
Boolean
Float
The literal True is of the Boolean data type, representing a logical truth value. Booleans have two values: True and False.
What does an 'if' statement do in a program?
Declares a variable
Repeats a block until a condition is false
Executes a block only if a condition is true
Defines a function
An 'if' statement evaluates a condition and executes its block only when that condition is true. It allows conditional control flow.
Which loop structure is best when you know the exact number of iterations beforehand?
while loop
do-while loop
for loop
if statement
A for loop is typically used when the number of iterations is known, as it iterates over a defined range or collection.
What will be printed by this Python code? for i in range(1, 5): if i % 2 == 0: print(i)
1, 2, 3, 4
2, 4
1, 3
No output
range(1,5) generates values 1 through 4, and the condition i % 2 == 0 is true only for 2 and 4, so those two numbers are printed.
What is the output of this function call in Python? def add(a, b=3): return a + b print(add(2))
5
Error
2
None
The function has a default parameter b=3. Calling add(2) uses that default, so it returns 2 + 3 = 5.
What is the time complexity of this loop as a function of n? sum = 0 for i in range(n): sum += i
O(1)
O(n)
O(log n)
O(n^2)
The loop runs a single pass from 0 to n−1, performing one operation per iteration, so the overall complexity is linear, O(n).
Which data structure follows the Last-In, First-Out (LIFO) principle?
Queue
Stack
Tree
Graph
A stack adds and removes items from the same end, so the most recently added item is the first removed, following LIFO.
What will be the value of x after this code executes? x = 10 if x > 5: x = x * 2 else: x = x + 5
20
15
10
5
Since x > 5 is true, the code inside the if block runs, multiplying x by 2 and yielding 20.
Which of the following will cause an infinite loop in Python?
while False: pass
while True: pass
for i in range(5): pass
if True: pass
A while True loop never meets a false condition, so it continues indefinitely, creating an infinite loop.
What is the output of this nested loop snippet? for i in range(2): for j in range(2): print(i + j, end=' ')
0 1 1 2
0 1 2 3
1 2 3 4
0 0 1 1
For i=0, j=0 and j=1 yield 0 and 1. For i=1, j=0 and j=1 yield 1 and 2, producing 0 1 1 2.
What does variable scope refer to in programming?
Order of operations in expressions
Range of values a variable can hold
Portion of code where a variable is accessible
Memory size allocated for variable
Scope defines which parts of the code can access a given variable, preventing unwanted side effects and naming conflicts.
What error will this code raise? print(value) value = 5
NameError
TypeError
ValueError
SyntaxError
Accessing a variable before it has been assigned a value leads to a NameError, as the name 'value' is not yet defined.
How many times will the following loop execute? i = 0 while i < 3: print(i) i += 1
2
3
4
Infinite times
The loop starts with i=0 and runs while i<3, printing 0, 1, and 2 before i becomes 3 and the loop ends, for a total of 3 iterations.
What is the time complexity of the following code in terms of n? for i in range(n): for j in range(n): print(i, j)
O(n)
O(n log n)
O(n^2)
O(2^n)
There are two nested loops each running n times, resulting in n × n total iterations, which is O(n²).
What is the time complexity of a binary search algorithm on a sorted list of size n?
O(n)
O(log n)
O(n log n)
O(1)
Binary search halves the search range each step, leading to logarithmic time complexity, O(log n).
What will this Python code print? numbers = [1, 2, 3] squared = [x * x for x in numbers] print(squared)
[1, 4, 9]
[1, 2, 3]
[2, 4, 6]
Error
The list comprehension iterates over each element in numbers and squares it, producing a new list [1, 4, 9].
Which of the following is an example of a pure function?
Reads a global variable and returns its value
Modifies a global list and returns None
Returns the sum of two inputs without side effects
Prints output to console and returns None
A pure function depends only on its inputs and has no side effects, such as I/O or modifying external state, so returning a sum of inputs qualifies.
Identify the output of this code snippet and explain the bug: def add_to_list(item, lst=[]): lst.append(item) return lst print(add_to_list(1)) print(add_to_list(2))
[1], [2]
[1], [1, 2]
[1, 2], [1, 2]
Error
The default list lst is evaluated once and reused, so the second call appends to the same list, producing [1] then [1, 2].
0
{"name":"What is the result of evaluating the expression 3 + 4 in most programming languages?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What is the result of evaluating the expression 3 + 4 in most programming languages?, Which of the following is a valid variable name in Python?, What data type does the boolean literal True represent in many programming languages?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}

Learning Outcomes

  1. Identify fundamental programming concepts such as variables, data types, and control flow
  2. Apply conditional statements and loops to solve basic code challenges
  3. Analyse simple algorithms for efficiency and correctness
  4. Demonstrate understanding of functions and modular code structure
  5. Evaluate common error messages and debug simple code snippets

Cheat Sheet

  1. Understand Variables and Data Types - Variables are like labeled jars where you store data that your program can use and change. Common jars hold integers, floats, strings, and booleans, each behaving differently in memory and operations. By choosing the right type, your code runs faster and avoids weird bugs! Correctly formatted link
  2. medium.com
  3. Master Conditional Statements - Use if, elif, and else to guide your code through different paths, like a GPS choosing the best way based on traffic. These statements let your program make decisions and respond dynamically as inputs change. Practice with silly conditions (for example, if pizza_remaining > 0: celebrate!) to nail the logic. Correctly formatted link
  4. codelearn.com
  5. Utilize Loops for Repetition - Loops let you repeat tasks without rewriting code, perfect for processing lists, counting, or running endless fun cycles (but watch out for infinite loops!). A for-loop spins a fixed number of times, while a while-loop keeps going until a condition flips. Master loops and you'll automate repetitive chores in a snap. Correctly formatted link
  6. medium.com
  7. Implement Functions for Modularity - Functions are magic boxes that take inputs, work their own logic, and dish out results, keeping your main code neat and tidy. By naming and reusing these boxes, you reduce repetition and make debugging a breeze. Start small with a greeting function, then watch your code grow like a well-organized library! Correctly formatted link
  8. miamioh.edu
  9. Analyze Algorithm Efficiency - Ever wonder why sorting a deck of cards by hand vs. a robot feels different speedwise? Algorithm efficiency measures how time and memory use scale with data size, using Big-O notation like O(n) or O(n²). By comparing these metrics, you pick the fastest tool for the job and avoid slow-motion nightmares! Correctly formatted link
  10. geeksforgeeks.org
  11. Debug Common Errors - Bugs are sneaky gremlins in your code, but understanding syntax, runtime, and logic errors arms you to catch them fast. Syntax errors shout about the wrong spelling and punctuation, runtime errors erupt during execution, and logic errors hide in plain sight. Turn on your detective hat, read error messages, and conquer those pesky bugs! Correctly formatted link
  12. realpython.com
  13. Practice Writing Clean Code - Think of your code as a recipe: clear instructions, meaningful ingredient names, and tidy steps make it easy for anyone to follow. Use descriptive names like user_age instead of x, consistent indentation, and comments that explain the why, not the what. Clean code means less headache for future you (and your teammates!). Correctly formatted link
  14. peps.python.org
  15. Understand Control Flow - Control flow is the roadmap your program follows, weaving through conditionals, loops, and function calls. Mastering these gates and paths lets you choreograph complex behaviors without getting lost in code spaghetti. Imagine being the conductor of a symphony, directing each instrument (or line of code) to shine at the right moment! Correctly formatted link
  16. programiz.com
  17. Learn Error Handling - When unexpected events happen, like dividing by zero or missing files, error handling steps in to catch exceptions and keep your program dancing instead of crashing. Python's try and except blocks let you anticipate problems, provide friendly messages, or fallback options. Embrace graceful failures to build robust, user-friendly apps! Correctly formatted link
  18. realpython.com
  19. Explore Object-Oriented Programming (OOP) - OOP is like crafting virtual blueprints (classes) that spawn real-world objects with attributes and abilities. You can create Car classes with make and model traits, and let methods (functions inside classes) drive behavior, making your code modular and super scalable. Master OOP and build games, GUIs, or any complex system like a pro architect! Correctly formatted link
  20. docs.python.org
Powered by: Quiz Maker