WorksheetsTA 1st Round Technical Coding
Total questions: 50
Worksheet time: 22mins
What is the correct file extension for Python files?
.pyt
.py
.python
.pt
Which keyword is used for defining a function in Python?
func
define
def
lambda
What is the output of the expression 5 // 2 in Python?
2.5
2
3
2.0
Which of the following data types is immutable?
List
Dictionary
Set
Tuple
What does the len() function do?
Finds the largest number
Returns the length of an object
Converts data types
Removes an element from a list
Which of these is the correct way to import a module?
import math
include math
using math
module math
What is the output of print(type(3.0))?
int
float
str
None
What does the is operator compare?
Value
Identity
Type
Length
Which of the following functions can be used to iterate over a sequence by index?
range()
enumerate()
zip()
map()
What is the default mode in which the open() function opens a file?
Write
Read
Append
Binary
What will be the output of the following code? python x = [1, 2, 3, 4] print(x[1:3])
[1, 2]
[2, 3]
[2, 3, 4]
[3, 4]
What is the output of the following code? python print(2**3**2)
512
64
16
9
Which function will convert a string into a list of words?
split()
list()
words()
slice()
What will be the output of this code? python def add(a, b=10): return a + b print(add(5))
15
10
5
Error
Which function can be used to find the maximum value in a list?
min()
sum()
max()
range()
What is the output of the following code? python x = [1, 2, 3] x.append(4) print(x)
[1, 2, 3, 4]
[1, 2, 3]
[1, 4]
Error
What is the output of the following code? python print(bool(0), bool(3.14))
True True
True False
False True
False False
What is the result of the following expression? python 3 * "Python"
"PythonPythonPython"
["Python", "Python", "Python"]
Error
None
What is the output of the following code? python x = {"a": 1, "b": 2} print(x.get("c", 3))
None
3
Error
0
What will list(range(1, 10, 2)) return?
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 3, 5, 7, 9]
[1, 3, 5, 7]
Error
What will be the output of this code? python a, b = b, a = 1, 2 print(a, b)
1 2
2 1
Error
1 1
What is the output of the following code? python print(0.1 + 0.2 == 0.3)
True
False
Error
None
What will be the output? python x = [1, 2, 3] print(x * 2)
[1, 2, 3, 1, 2, 3]
[2, 4, 6]
[1, 2, 3]
Error
What will this code output? python print("abc" * 0)
abc
None
""
Error
What is the result of this code? python x = 10 print(x == 10 and x > 5)
True
False
Error
None
What is the output of the following? python x = [1, 2, 3] y = x y.append(4) print(x)
[1, 2, 3]
[1, 2, 3, 4]
[4]
Error
What will this print? python print(sorted([3, 2, 1], reverse=True))
[1, 2, 3]
[3, 2, 1]
Error
None
What is the output? python print(bool([]))
True
False
Error
None
What will this code produce? python print("Python"[::-1])
"nohtyP"
"Python"
""
Error
What is the output of the following code? python print({1, 2, 3} & {2, 3, 4})
{2, 3}
{1, 4}
{1, 2, 3, 4}
None
What will this code output? python print("abc" * 0)
abc
None
""
Error
What is the result of this code? python x = 10 print(x == 10 and x > 5)
True
False
Error
None
What is the output of the following? python x = [1, 2, 3] y = x print(x)
[1, 2, 3]
[1, 2, 3, 4]
[4]
Error
What will this print? python print(sorted([3, 2, 1], reverse=True))
[1, 2, 3]
[3, 2, 1]
Error
None
What is the output? python print(bool([]))
True
False
Error
None
What will this code produce? python print("Python"[::-1])
"nohtyP"
"Python"
""
Error
What is the output of this code? c int a = 10; printf("%d", a);
10
%d
Error
None of the above
Which library function is used to find the length of a string?
strlen()
size()
length()
strlength()
What is the value of x after executing the following code? c int x = 5; x++;
5
6
7
Undefined
Which of the following is not a valid storage class in C?
auto
register
static
mutable
What is the size of the int data type in most systems?
a) 2 bytes
b) 4 bytes
c) 8 bytes
d) System-dependent
Which of the following is the correct syntax for a comment in C?
a) // This is a comment
b) <!-- This is a comment -->
c) /* This is a comment */
d) ''' This is a comment'''
What does the sizeof operator do?
a) Allocates memory
b) Returns the size of a data type or variable in bytes
c) Compares two variables
d) None of the above
Which of the following is used to end a switch statement in C?
(a)
What is the output of the following code?*
c
int arr[] = {1, 2, 3};
printf("%d", arr[2]);
(a)
Which of the following functions is used to copy strings in C?
(a)
What is the time complexity of accessing an element in an array?*
(a)
25. What is the output of the following code?*
c
#define SQUARE(x) x*x
printf("%d", SQUARE(5+1));
(a)
27. What is the output of the following code?
c
char *str = "Hello";
printf("%c", *(str+1));
(a)
29. What is the output of the following code?
c
int x = 1;
if (x = 0)
printf("True");
else
printf("False");
(a)
