
Ctrl+Solve

Quiz
•
Computers
•
University
•
Hard
Muhammed Nihal Noushad
Used 8+ times
FREE Resource
25 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
def add_item(item, lst=[ ]):
lst.append(item)
return lst
print(add_item(1))
print(add_item(2))
print(add_item(3, [ ]))
print(add_item(4))
What is the output?
[1] [2] [3] [4]
[1] [1, 2] [3] [1, 2, 4]
[1] [2] [3] [4]
[1] [1, 2] [3] [4]
2.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
A short snippet is displayed in a scrambled order. Which option shows the correct order for the code?
Scrambled Snippet:
printf("Result: %d", calculate(3));
int calculate(int n) {
return n > 0 ? n * calculate(n - 1) : 1;
}
Expected Output:
Result: 6
int calculate(int n) {
return n > 0 ? n * calculate(n - 1) : 1;
}
printf("Result: %d", calculate(3));
printf("Result: %d", calculate(3));
int calculate(int n) {
return n > 0 ? n * calculate(n - 1) : 1;
}
int calculate(int n);
printf("Result: %d", calculate(3));
int calculate(int n) {
return n > 0 ? n * calculate(n - 1) : 1;
}
int calculate(int n) {
return n > 0 ? n + calculate(n - 1) : 1;
}
printf("Result: %d", calculate(3));
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include<stdio.h>
void recurse() {
int arr[1000]; // Large stack allocation
recurse();
}
int main() {
recurse();
return 0;
}
What is the error?
No error, infinite recursion allowed
Stack overflow due to uncontrolled recursion
Compilation error due to large array
Undefined behavior
4.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
x = 0 or None or [ ] or { } or 42
print(x)
What will be printed?
0
None
[ ]
42
Answer explanation
• The or operator returns the first truthy value or the last falsy value if all are falsy.
• 0, None, [], {} are all falsy, so Python keeps evaluating.
• 42 is truthy, so it is returned.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
x = 10
def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner()
print(outer(), x)
What is the output?
6 10
6 6
UnboundLocalError
5 10
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
A short snippet is displayed in a scrambled order. Which option shows the correct order for the code?
Scrambled Snippet:
printf("Value: %d", arr[2]);
arr[2] += modify(arr[1]);
int arr[ ] = {1, 2, 3, 4};
int modify(int x) {
return x * 2;
}
Expected Output:
Value: 7
int modify(int x) {
return x * 2;
}
int arr[ ] = {1, 2, 3, 4};
arr[2] += modify(arr[1]);
printf("Value: %d", arr[2]);
printf("Value: %d", arr[2]);
arr[2] += modify(arr[1]);
int arr[ ] = {1, 2, 3, 4};
int modify(int x) {
return x * 2;
}
int arr[ ] = {1, 2, 3, 4};
arr[2] += modify(arr[1]);
printf("Value: %d", arr[2]);
int modify(int x) {
return x * 2;
}
int modify(int x);
int arr[ ] = {1, 2, 3, 4};
arr[2] += modify(arr[1]);
printf("Value: %d", arr[2]);
int modify(int x) {
return x + 2;
}
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#include<stdio.h>
#include<stdlib.h>
int* createNumber() {
int num = 42;
return #
}
int main() {
int* ptr = createNumber();
printf("%d", *ptr);
return 0;
}
What is the error?
No error, prints 42
Undefined behavior due to returning a local variable's address
Segmentation fault
Compilation error
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
Programming Concepts in C

Quiz
•
University
20 questions
CSE C Section

Quiz
•
University
20 questions
TES Pemahaman Materi

Quiz
•
University
20 questions
Quantitative Aptitude Series

Quiz
•
University
20 questions
Parcial 3 - Fundamentos de Programacion

Quiz
•
University
22 questions
C Language Loop and Array Quiz

Quiz
•
University
25 questions
C PROGRAMMING

Quiz
•
University
20 questions
Code-A-Vita

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University