WorksheetsCoding Competition and hackathon
Total questions: 60
Worksheet time: 34mins
What is a variable in programming?
A variable is a command that executes a function in programming.
A variable is a symbolic name for a storage location in programming that can hold data and whose value can change.
A variable is a type of error that occurs during program execution.
A variable is a fixed value that cannot be changed in programming.
Explain the difference between a list and a tuple.
A list is a fixed size; a tuple can grow or shrink.
A list is ordered; a tuple is unordered.
A list is mutable; a tuple is immutable.
A list can contain only numbers; a tuple can contain any type.
What is the purpose of a loop in programming?
Loops are designed to handle errors in code.
The purpose of a loop is to create a new function.
A loop is used to store data in a variable.
The purpose of a loop in programming is to repeat a set of instructions until a condition is satisfied.
Define a stack and its basic operations.
A stack is a circular data structure with operations: add (push), take (pop), and last (retrieve end).
A stack is a linear data structure with operations: insert (add), delete (remove), and top (retrieve last).
A stack is a LIFO data structure with operations: push (add), pop (remove), and peek (retrieve top).
A stack is a FIFO data structure with operations: enqueue (add), dequeue (remove), and front (retrieve first).
What is a queue and how does it differ from a stack?
A queue is a linear structure; a stack is circular.
A queue allows random access; a stack does not.
A queue is LIFO; a stack is FIFO.
A queue is FIFO; a stack is LIFO.
What is the time complexity of accessing an element in an array?
O(1)
O(n^2)
O(log n)
O(n)
Describe the concept of recursion with an example.
Recursion involves breaking down a problem into unrelated parts, such as merging lists.
Recursion is a method where a function calls itself to solve smaller instances of a problem, exemplified by the factorial function.
Recursion is a process where a function iterates over a loop to achieve a result, similar to the Fibonacci sequence.
Recursion is a technique where a function runs in parallel to increase efficiency, like sorting algorithms.
What is a binary search tree?
A binary search tree is a type of graph where nodes can have multiple parents and no specific order.
A binary search tree is a collection of nodes where each node can have three or more children, arranged randomly.
A binary search tree is a linear data structure that stores elements in a sequential manner without any hierarchy.
A binary search tree is a data structure where each node has at most two children, with the left child containing values less than the node and the right child containing values greater.
Explain the difference between a linear search and a binary search.
Linear search requires a specific key, while binary search can find any element.
Linear search is faster for large datasets, while binary search is slower for small lists.
Linear search checks each element one by one, while binary search divides the list and checks the middle element.
Linear search uses a sorted list, while binary search works on unsorted data.
What is the purpose of debugging in software development?
To gather user feedback for future updates and features.
To increase the software's processing speed and efficiency.
The purpose of debugging in software development is to identify and fix bugs to ensure the software operates correctly.
To enhance the aesthetic design of the software interface.
What are unit tests and why are they important?
Unit tests are random tests for software performance, important for user satisfaction.
Unit tests are automated tests for individual components of software, crucial for early bug detection and ensuring code quality.
Unit tests are documentation tools for software features, vital for project management.
Unit tests are manual checks for entire applications, essential for user interface design.
What is an API and how is it used in programming?
An API is a programming language used for web development.
An API is a graphical interface for designing software applications.
An API is a set of rules that allows different software applications to communicate and is used in programming to integrate external functionalities.
An API is a database management tool for storing data.
What does REST stand for in the context of APIs?
Resourceful State Transfer
Representational State Transfer
Representational Static Transfer
Remote State Transfer
What is version control and why is it important?
Version control is a method for creating backups and is not essential for teamwork.
Version control is important because it facilitates collaboration, maintains a history of changes, and allows for easy recovery of previous versions.
Version control tracks only the final version of files and ignores previous changes.
Version control is only useful for large software projects and not for small teams.
Explain the difference between Git and SVN.
SVN is faster than Git for large projects.
Git is distributed; SVN is centralized.
Git uses a single repository; SVN uses multiple repositories.
Git requires a constant internet connection; SVN does not.
What command is used to create a new branch in Git?
git create
git branch
git new-branch
git checkout -b
What is a merge conflict in version control?
A merge conflict occurs when all changes from branches are combined successfully.
A merge conflict happens when a branch is merged without any changes made.
A merge conflict is when one branch is deleted during the merging process.
A merge conflict is a situation in version control where changes from different branches cannot be automatically merged due to conflicting modifications.
How do you revert a commit in Git?
Use 'git revert
Use 'git reset
Run 'git checkout
Execute 'git delete
What is the purpose of a README file in a project?
To list all contributors to the project.
To provide a detailed technical specification.
To serve as a marketing tool for the project.
The purpose of a README file in a project is to provide essential information and instructions about the project.
What is the significance of code comments?
Code comments replace the need for documentation.
Code comments are only useful for beginners.
Code comments enhance code clarity and maintainability.
Code comments slow down the coding process.
which of the following python code gives output 9?(a=5,b=4)
data = a & b
a = a ^ b
b = data << 1
data = a & b
a = a ^ b
b = data >> 1
data = a ^ b
a = a & b
b = data << 1
data = a >> b
a = a & b
b = a^b
Is python supports multi-threading?
which of the following code will replaces space with a given character in python?
string = "Hello World"
character = "-"
new_string = string.replace(" ", character)
print(new_string)
string = "Hello World"
character = "-"
table = str.maketrans(" ", character)
new_string = string.translate(table)
print(new_string)
Both 1 &2
None
If two lists containing the same elements at different positions are called
(ex: silent and listen)
(a)
What does URL stand for?
Uniform Resource Locator
Uniform Resource Location
Uniform Reset Locator
Unified Resource Locator
Which of the following is a graph traversal algorithm?
Breadth first search
Depth first search
Dijkstra's algorithm
All of the above
What is the output of the following program?
from math import *
a = 2.13
b = 3.7777
c = -3.12
print(int(a), floor(b), ceil(c), fabs(c))
2 3 -4 3
2 3 -3 3.12
2 4 -3 3
2 3 -4 3.12
What is the time complexity for checking if an undirected graph with E edges and V vertices is Bipartite, given its adjacency matrix?
O(E)
O(V*V)
O(E*E)
O(V)
An unrestricted use of the "goto" statement is harmful because
Which of the following statements are CORRECT?
1) Static allocation of all data areas by a compiler makes it impossible to implement recursion.
2) Automatic garbage collection is essential to implement recursion.
3) Dynamic allocation of activation records is essential to implement recursion.
4) Both heap and stack are essential to implement recursion.
1 and 2 only
2 and 3 only
3 and 4 only
1 and 3 only
Consider the function func shown below:
def func(num):
count = 0
while num:
count += 1
num >>= 1
return count
The value returned by func(435) is _________.
A three-member committee has to be formed from a group of 9 people. How many such distinct committees can be formed?
Hema's age is 5 years more than twice Hari's age. Suresh's age is 13 years less than 10 times Hari's age. If Suresh is 3 times as old as Hema, how old is Hema?
The most efficient algorithm for finding the number of connected components in an undirected graph on n vertices and m edges has time complexity
O(n)
O(m)
O(n+m)
O(nm)
A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node should p point such that both the operations enQueue and deQueue can be performed in constant time?
Consider the following function:
def unknown(n):
k = 0
for i in range(n//2, n+1):
j = 2
while j <= n:
k = k + n//2
j = j * 2
return k
The return value of the function is
O((n//2) * n)
O(n2*logn)
O(n * log(n))
O(n * (n//2))
The tightest lower bound on the number of comparisons, in the worst case, for comparison-based sorting is of the order of
Which of the following statements is correct regarding the object-oriented programming concept in Python?
Classes are real-world entities while objects are not real
Objects are real-world entities while classes are not real
Both objects and classes are real-world entities
All of the above
What is agg() function?
what are the types of gready algorithms?
Dijkstra's Algorithm
Prim's Algorithm
Huffman Coding
Fractional Knapsack
What is the best way to debug a Python program?
What does "yield" keyword in python imply?
Expand PEP in python?
Python Extension Protocol
Python Enhancement Proposal
which of the following function can be used to generate random numbers?
random( )
randint( )
uniform( )
range( )
Which of the following sorting algorithms has the best average-case time complexity?
Quick Sort
who created python?
(a)
what is the output of the following code
def myfunc(n):
for i in range(0, n):
for j in range(0, i+1):
print(" * ",end="")
print("\r")
which of the following pair of words are anagrams?
night and thing
Which algorithm is used for finding the strongly connected components in a graph?
Bellman-Ford algorithm
What is the space complexity of the iterative implementation of the Fibonacci sequence?
O(n)
O(1)
O(log n)
O(n^2)
What does AVL tree guarantee?
O(log n) time complexity for insert, delete, and search operations
O(n) time complexity for insert, delete, and search operations
O(n log n) time complexity for insert, delete, and search operations
O(n^2) time complexity for insert, delete, and search operations
out put of the following code?
#include <stdio.h>
enum week { Mon, Tue, Wed, Thur, Fri, Sat, Sun };
int main()
{
enum week day;
day = Wed;
printf("%d", day);
return 0;
}
2
3
It gives error
None
output of the following code?
#include <stdio.h>
int main(){
if (printf(“Hello - World”)) {
}return 0;
}
It gives Error
Hello - World
Neither 1 or 2
None
what is the correct way to declare pointer in c?
int var(*ptr);
int **ptr;
what is the output of the code given below?
#include "stdio.h"
int main()
{
char a[] = { 'A', 'B', 'C', 'D' };
char* ppp = &a[0];
*ppp++;
printf("%c %c ", ++ppp, --ppp);
}
C B
B A
B C
C A
What will be the output of the following program?
#include <stdio.h>
int main(void)
{
int i = 40 >> 5 << 3 >> 2 << 1;
printf("%d", i);
return 0;
}
0
4
1
40
C supports multithreading?
True
False
Predict the output of below C program?
#include<stdio.h>
int main(void){
int a = 1;
int b = 0;
b = ++a + ++a;
printf("%d %d",a,b);
getchar();
return 0;
}
3 6
3 0
3 5
3 4
who is he?
(a)
