wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Conditionals

Total questions: 18

Worksheet time: 2hrs 0mins

Name
Class
Date
1.
What is my result?
mickey = mouse                                   .
if mickey == mouse:                           .
.            print("Mickey is a mouse")
.else:                                                             .
.         print("Minnie rules")        .
a)
"Mickey is a mouse"
b)
"Minnie rules"
c)
Nothing prints.
d)
"Mickey is a mouse" & "Minnie rules"
2.
What is my result?
john = 5                                                                        .
if john > 6:                                                                  .
.            print("John is getting ice cream")
else:                                                                               .
.               print("John is getting apple juice")
print("John is getting grapes")                    .
a)
John is getting ice cream
John is getting grapes
b)
John is getting apple juice
John is getting grapes
c)
John is getting apple juice
d)
John is getting ice cream
3.
What is my result?
john = 10                                                                     .
if john > 6:                                                                  .
.            print("John is getting ice cream")
else:                                                                               .
.               print("John is getting apple juice")
print("John is getting grapes")                    .
a)
John is getting ice cream
John is getting grapes
b)
John is getting apple juice
John is getting grapes
c)
John is getting apple juice
d)
John is getting ice cream
4.
What is my result?
john = 5                                                                        .
if john > 6:                                                                  .
.            print("John is getting ice cream")
else:                                                                               .
.               print("John is getting apple juice")
.      print("John is getting grapes")
a)
John is getting ice cream
John is getting grapes
b)
John is getting apple juice
John is getting grapes
c)
John is getting apple juice
d)
John is getting ice cream
5.
What is my result?
john = 8                                                                        .
if john > 6:                                                                  .
.            print("John is getting ice cream")
else:                                                                               .
.               print("John is getting apple juice")
       print("John is getting grapes")
a)
John is getting ice cream
John is getting grapes
b)
John is getting apple juice
John is getting grapes
c)
John is getting apple juice
d)
John is getting ice cream
6.
What is this operator? &&
a)
and
b)
or
c)
Remainder or mod
d)
Multiplication
7.
What is this operator? ==
a)
Equal to
b)
Used in a calculation for equals
c)
and
d)
or
8.
What is this operator? ||
a)
and
b)
or
c)
Remainder or mod
d)
Division
9.
What is this operator? !
a)
and
b)
or
c)
not
d)
equal to
10.
// Select the line with an error       
int count = 3;                                           
if ( count <= 4)     // a                           
{                                                                     
 
count = count + 7         // b
 
}                                                                     
 else       // c                                                 
count = count * 2;   // d     
Console.WriteLine(count + 1); 
a)
a
b)
b
c)
c
d)
d
11.
//What is the result
int count = 3;                                           
if ( count <= 4)                                       
{                                                                     
count = count + 7;         
}                                                                     
 else                                                               
count = count * 2;         
Console.WriteLine(count + 1); 
a)
7
b)
8
c)
10
d)
11
12.
//What is the result
int count = 3;                                           
if ( count <= 4)                                       
{                                                                     
count = count + 7;         
}                                                                     
 if (count > 4)                                           
count = count * 2;         
Console.WriteLine(count + 1); 
a)
7
b)
11
c)
21
d)
201
13.
//What is the result
string count = "3";                             
 if (count == "3")                                   
count = count + 1;         
if (count == "4")                                   
                      count = count + 2;                             
 if (count == "3")                                   
count = "0";                     
Console.WriteLine(count);         
a)
0
b)
3
c)
6
d)
31
14.
//What is the result
int count = 3;                                           
 if (count < 2)                                           
count = count + 1;         
else if (count < 3)                                 
                      count = count + 2;                             
 if (count < 4)                                           
count = count + 3;         
Console.WriteLine(count);         
a)
4
b)
5
c)
6
d)
8
15.
There is an error in the code above. What line is the error in?
a)
Line 1
b)
Line 3
c)
Line 5
d)
none of the above
16.
There is an error in the code above. What line is the error in?
a)
Line 1
b)
Line 3
c)
Line 5
d)
none of the above
17.
What is the result of running this code?
a)
You're living a good life!
b)
You're living a fantastic life!
c)
You're too young!
d)
The code runs with errors
18.
What is the result of running this code?
a)
You're living a good life!
b)
You're too young!
c)
Runs with errors
d)
None of the above