WorksheetsCoding Assignment
Total questions: 30
Worksheet time: 15mins
What is the purpose of the "elif" statement in Python?
ment.
It is used to handle exceptions.
It is used to define a block of code that executes if the condition in the "if" statement is true.
It is used to define a block of code that executes if the condition in the preceding "if" statement is false.
It is used to define additional conditions to be checked after the initial "if" state
What is the output of the following
code snippet in Python?
my_list = [1, 2, 3, 4, 5]
my_list[2] = 6
print(my_list)
[1, 2, 6, 4, 5]
[1, 2, 6, 4]
[1, 2, 3, 6, 5]
[1, 2, 3, 4, 5, 6]
Which of the following is an example
of a relational operator in Python?
+
/
==
&&
What is the output of the following
code snippet in Python?
print("Hello" + "World")
Hello World
HelloWorld
Hello + World
Error
What does the following code snippet
do?
x = 5 y = 2 result = x // y
Performs integer division and stores
the quotient in the variable 'result'
Calculates the remainder of x divided
by y and stores it in the variable 'result'
Raises x to the power of y and stores
the result in the variable 'result'
Multiplies x and y and stores the
product in the variable 'result'
Which of the following is an example
of a loop that executes a fixed number of times?
while loop
for loop
do-while loop
switch statement
Which of the following is not a valid
programming language?
Python
Java
HTML
MongoDB
What will be the output of the
following code snippet?
x = [1, 2, 3, 4, 5] print(x[2:4])
[2, 3]
[3, 4]
[2, 3, 4]
[3]
Which data structure follows the
"last-in, first-out" (LIFO) principle?
Queue
Stack
Linked List
Tree
What is the output of the following
code snippet in Python?
def outer_function(x):
def inner_function(y):
return x + y
return inner_function
closure = outer_function(10)
result = closure(5)
print(result)
10
5
15
50
Which of the following is a valid way
to comment a single-line code in Python?
/* comment */
<!-- comment -->
# comment
/* comment */
What is the correct way to check if a
key exists in a dictionary?
What does the range() function
return?
A list of integers
A tuple of integers
A generator object
A dictionary
How can you check the length of a
string in Python?
What is the correct HTML tag for
inserting a line break?
<br>
<break>
<lb>
<line-break>
What is the correct HTML syntax to
include an external JavaScript file?
<script>src="script.js"></script>
<javascript>src="script.js"</javascript>
<link>src="script.js"</link>
<js>src="script.js"</js>
"null"
"undefined"
"object"
"boolean"
How to create a hyperlink in HTML?
<a href = "javatpoint.com">
javaTpoint.com </a>
<a url =
"javatpoint.com" javaTpoint.com /a>
<a link =
"javatpoint.com"> javaTpoint.com </a>
<a> javatpoint.com
<javaTpoint.com /a>
How to add a background color in
HTML?
<marquee bg color:
"red">
<marquee bg-color =
"red">
<marquee bgcolor =
"red">
<marquee color =
"red">
What will be the output of the
following code snippet?
var x = 10;
function foo() {
console.log(x);
var x = 20;
}
foo();
10
20
undefined
ReferenceError
What is the value of result after
executing the following JavaScript code?
let result = [1, 2, 3] + [4, 5, 6];
[1, 2, 3, 4, 5, 6]
"123456"
NaN
SyntaxError
Which of the following is true about
functions in JavaScript?
A function must always return a value
A function can only accept a fixed number
of arguments
A function can be assigned to a
variable
A function can only be called once
per program execution
What is the correct way to declare a
JavaScript variable?
var myVariable;
variable myVariable;
let myVariable;
const myVariable;
4
22
"22"
NaN
Which of the following CSS framework is used
to create a responsive design?
django
rails
larawell
bootstrap
Which CSS selector targets an element
with a specific ID?
.
#
>
*
.
What does CSS stand for?
Cascading Style Sheets
Creative Style Sheets
Computer Style Sheets
Colorful Style Sheets
What is the correct CSS syntax to
apply a red background color to all paragraphs with the class
"highlight"?
.highlight { background-color: red; }
#highlight { background-color: red; }
p.highlight { background-color: red;}
highlight.p { background-color: red;}
What is the correct way to set the font size of an element to 16 pixels in CSS?
font-size: 16px;
font-size: 16;
size: 16px;
text-size: 16px;
