Font size
WorksheetsIf,elif,loop
Total questions: 24
Worksheet time: 14mins
What is the output of the following loop:-
for l in 'Jhon':
if l == 'o':
pass
print(l, end=", ")
J, h, n,
J, h, o, n,
Error
None of the given Options
What is the output of the following range() function?
for num in range(2,-5,-1):
print(num, end=", ")
2, 1, 0
2, 1, 0, -1, -2, -3, -4, -5
2, 1, 0, -1, -2, -3, -4
0
Given the nested if-else below, what will be the value x when the code is executed successfully.
0
4
2
3
Given the nested if-else structure below, what will be the value of x after code execution completes.
2
0
3
4
What is the output of the following nested loop?
10 Chair
10 Table
20 Chair
20 Table
10 Chair
10 Table
What is the value of x?
101
None of the given options, this is an infinite loop
99
100
What is the output of the following if statement?
False
True
What is the output of the following for loop and range() function?
-2, -1, -3, -4
-2, -1, 0, 1, 2, 3
-2, -1, 0
-2, -3, -4
What is the value of the var after the for loop completes its execution?
20
21
10
30
What is the value of x after the following nested for loop completes its execution?
99
90
100
0
What is the output of the following nested loop?
10
11
12
13
11
13
What is the output of the following nested loop?
10
11
12
13
11
13
Select which is true for: (for loop).
Hint: (We use while loop when we want to perform a task indefinitely until a particular condition is met.)
Python’s for loop used to iterates over the items of list, tuple, dictionary, set, or string.
We use for loop when we want to perform a task indefinitely until a particular condition is met
else clause of for loop is executed when the loop terminates abruptly
else clause of for loop is executed when the loop terminates naturally
In programming, what is iteration?
The repetition of steps within a program
The order in which instructions are carried out
A decision point in a program
Testing a program to make sure it works
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
The above program prints
Numbers 1 to 10 in reverse order
Numbers 1 to 11 in reverse order
Numbers 1 to 10
Numbers 1 to 11
How many times will 1 be printed
3
4
5
6
Which of the following statements contains an error?
Select * from emp where empid = 10003;
Select empid from emp where empid = 10006;
Select empid from emp;
Select empid where empid = 1009 and lastname = ‘GELLER’;
SELECT last_name, salary, (a)
FROM employees;
SELECT last_name "Name" , salary*12 "_____ _____"
FROM employees;
(a)
SELECT (a) AS "Employees"
FROM employees;
SELECT last_name ||' (a) '||job_id
AS "Employee Details"
FROM employees;
