Font size
WorksheetsControl Statements and Looping
Total questions: 99
Worksheet time: 1hrs 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
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
WHILE 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 result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
True
False
condition1
condition2
What is the output?
more than 7
more than 23
spam
7
What is the output?
250.0
200.0
300.0
350.0
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
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 if statement?
False
True
What is the result of the code:
team = Cowboys
if team = Cowboys:
print(Dallas is #1)
Error
Cowboys
Team
Dallas is #1
What is the output?
more than 7
more than 23
spam
7
Pieces of code that only run "under certain conditions":
conditional statements
control flow statments
syntax
variables
Which symbol means "not equal to"?
==
<=
>=
!=
Which character must be at the end of the line for if?
:
;
.
{
What does the = = symbol mean in Python?
Equal to or shows equality
Not Equal
Code that will be skipped
End of clause
What is the output?
True
False
condition1
condition2
What is the output?
250.0
200.0
300.0
350.0
What will be displayed at the end of the program?
Case 1
Case 2
Nothing will be displayed.
Case 1 and Case 2
What will be displayed at the end of the program?
Case 1
Case 2
Nothing will be displayed.
Case 1 and Case 2
What will display at the end of the program running?
You can ride the carousel!
Nothing will display
You cannot ride the carousel!
There will be an error.
What will display at the end of the program running?
You can ride the carousel!
Nothing will display
Sorry! Not tall enough!
There will be an error.
What will display at the end of the program running?
You can ride the carousel!
Nothing will display
Sorry! Not tall enough!
There will be an error.
What questions do you have about If Else Statements?
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
Given the nested if-else below, what will be the value x when the code is executed successfully.
0
4
2
3
Fill the blank
counter=1
counter<10
counter<=10
counter<=11
What is an algorithm?
A set of steps for performing a task, like a recipe.
To add something to the end; for example, adding letters onto the end of a string or adding elements to the end of a list or array.
A value passed to a function.
A rhythm designed for people named "Al."
What is an application?
A computer program that does something useful (or fun!).
A request to do something.
A set of steps for performing a task, like a recipe.
A group of programming statements.
Statements or instructions written by a programmer in a language that computers can understand defines...
algorithm
code
software
range
A set of instructions that is repeated until a condition is reached is
a loop
code
a function
an expression
Which loop will repeat the information in the loop # times before stopping the program?
Forever
Repeat #
Repeat until ___
Which loop continues an infinite number of times unless the user stops it?
Forever
Repeat #
Repeat until ___
Which loop repeats itself until the X statement is true?
Forever
Repeat #
Repeat until ___
A ____________ is a special control block that expects a predicate (what is in the picture).
Variable
Predicate
Conditional
Reporter
Which of the following could be a SPRITE? (Check as many as apply.)
a tomato
a sports ball
a hero
an animal
Statements that run only under certain conditions or situations.
conditionals
nested loop
command
refactor
Select different parts of "for" looping statement-
Initialization part
Condition Part
Update part
All of these
What will be the output of following code- for(int i = 1; i < 5; i++ )
{
System.out.print(i);
}
13
135
1234
12345
_________ in programming come into use when we need to repeatedly execute a block of statements.
nested for loop
none
for loop
loop
The __________ statement uses single expression for multiple choices
loop
switch
multiple value
if else
in __________ the controlling condition appears at the start of the loop and _______ at the end of the loop
While / Do while
Do while/While
None
What is an Array?
A group of elements of same data type.
An array contains more than one element
Array elements are stored in memory in continuous or contiguous locations.
All the above.
In general, the index of the first element in an array is __________
0
-1
2
1
What is meaning of following
declaration ?
int arr[20];
Array of size 20 that can have integer address
Array of Size 20
Integer Array of size 20
None of these
Assuming int is of 2 bytes, what is the size of int arr[15];?
15
19
11
30
What is the length of the following array: int data[] = { 12, 34, 9, 0, -62, 88 };
1
5
6
12
If we have declared an array described below -
int arr[6];
then which of the following array element is considered as last array element ?
arr[6]
arr[4]
arr[0]
arr[5]
All the arithmetic operators operate on (a) associativity.
The symbol used for conditional operator is _____
?:
=
++
>=
The word algorithm is derived from the following
a. AL-KHOWARIZMI
b. AL-AHMED
c. AL-JAFAR
d. AL-MURA
The special function called ____ is where program execution begins.
a. Add
b. Sub
c. Main
d. Multi
Escape sequence _______ represents bell sound.
a. \n
b. \a
c. \t
d. \b
The meaning of the operator ______ is modulus in C language.
a. ++
b. mod
c. %
d. *
In the following declaration,
int sum(int , int);
How many parameters are declared?
a. 4
b.6
c. 2
d. 3
Function declaration or function prototype has ____ components.
a. 4
b. 7
c. 9
d. 3
Use repeat block to make the code shorter.
What do you think will happen when you click "Run"?
BB-8 will not move.
BB-8 will move only one space
BB-8 will move 5 times and get all of the scrap metal
BB-8 will move only 3 spaces.
Use a repeat block to move tho robot and collect all scrap metals.
Pick two repeat block to complete the code.
Identify wrong block in this code.
1
2
3
4
Use one repeat block for coding.
Identify the bug (mistake) in this code?
1
2
3
4
How many repetition needed to run two blocks in this code?
1
2
3
4
Use one repeat block to make the code shorter.
Use a repeat block to complete the code.
