
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
9.4.25 Mentoring quiz

Quiz
•
University
20 questions
Programming in C(1)

Quiz
•
University
23 questions
Beginning C Programming

Quiz
•
University
25 questions
C Quiz 1

Quiz
•
University
20 questions
Linux 3-4

Quiz
•
University
20 questions
Operator in C

Quiz
•
University
20 questions
C Programming Unit-1 Test-2

Quiz
•
University
20 questions
C Quest 2.0

Quiz
•
University
Popular Resources on Wayground
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade