WorksheetsProgramming Sandbox 2
Total questions: 40
Worksheet time: 21mins
Which of the following is a valid variable name in Python?
2number
number_2
number-2
number 2
What is the output of the following code?
print(5 + 3)
53
8
5+3
15
Which operator is used for multiplication in Python?
+
*
/
%
Which of the following is a comparison operator in Python?
=
==
:=
++
What is the result of the following expression: 7−4 ?
3
11
4
7
Which function is used to display output in Python?
output()
print()
show()
display()
Which of the following is a logical operator in Python?
and
plus
not_equal
add
What is the data type of the value 3.14 in Python?
int
float
str
bool
Which statement will assign the value 10 to the variable x?
x == 10
x := 10
x = 10
10 = x
What does the following code print? print("Hello, World!")
Hello World
Hello, World!
"Hello, World!"
HelloWorld
Which of the following expressions evaluates to True?
5 > 10
7 == 7
3 < 2
8 != 8
What is the output of the following code? x = 4 y = 2 print(x / y)
2
2.0
4
0.5
Which of the following statements will print "Yes" if the variable score is greater than 50?
if score > 50: print("Yes")
if score = 50: print("Yes")
if score < 50: print("Yes")
if score == 50: print("Yes")
What will be the value of z after executing the following code? x = 5 y = 3 z = x * y
8
15
2
53
Which of the following will evaluate to False?
10 < 20 and 5 > 2
7 == 7 or 3 > 5
not (4 == 4)
6 != 6
What is the output of the following code? a = 8 b = 2 print(a // b)
4
4.0
8
0.25
Which of the following is the correct way to check if a variable x is not equal to 10?
if x =! 10:
if x != 10:
if x <> 10:
if x not 10:
What is the output of the following code? x = 7 if x > 5: print("Big") else: print("Small")
Big
Small
7
Error
Which of the following will print "True"? a = 3 b = 5 print(a < b and b > 2)
True
False
3
5
What is the output of the following code? ```python x = 10 y = 5 if x == y: print("Equal") else: print("Not Equal") ```
Equal
Not Equal
10
5
Given the following code, what will be printed? x = 4 y = 6 if x + y > 10: print("High") else: print("Low")
High
Low
10
4
Which of the following code snippets will print "Pass" only if both math and science scores are above 60?
if math > 60 or science > 60: print("Pass")
if math > 60 and science > 60: print("Pass")
if math >= 60 and science >= 60: print("Pass")
if math > 60: print("Pass")
What will be the output of the following code? x = 3 y = 7 if x * y > 20: print("Large") else: print("Small")
Large
Small
21
Error
Which of the following expressions will result in True?
(5 > 3) and (2 < 1)
(4 == 4) or (6 < 2)
not (7 > 8)
(3 != 3) and (1 == 1)
Given the code below, what will be printed? x = 12 if x % 2 == 0: print("Even") else: print("Odd")
Even
Odd
12
Error
Which of the following code snippets will print "Yes" if either a is greater than 10 or b is less than 5?
if a > 10 and b < 5: print("Yes")
if a > 10 or b < 5: print("Yes")
if a >= 10 and b <= 5: print("Yes")
if a == 10 or b == 5: print("Yes")
What will be the output of the following code? ```python x = 5 y = 10 if x > y: print("x is bigger") else: print("y is bigger") ```
x is bigger
y is bigger
5
10
Which of the following will print "True" if x is between 1 and 10 (inclusive)?
if x > 1 and x < 10: print("True")
if x >= 1 and x <= 10: print("True")
if x == 1 or x == 10: print("True")
if x > 0 and x < 11: print("True")
Given the following code, what will be printed? x = 9 y = 3 if x / y == 3: print("Yes") else: print("No")
Yes
No
3
9
Which of the following code snippets will print "Equal" if a and b are the same, and "Not Equal" otherwise?
if a = b: print("Equal") else: print("Not Equal")
if a == b: print("Equal") else: print("Not Equal")
if a != b: print("Equal") else: print("Not Equal")
if a == b: print("Not Equal") else: print("Equal")
In the following code, n is a/an _______?
n = '5'
integer
string
tuple
operator
What is a string in programming?
A type of function
A collection of integers
An ordered sequence of characters
A type of boolean value
Which of the following is a characteristic of a string?
It can execute functions
It is a primary data type for storing numerical values
It represents text as a sequence of characters
It can only contain spaces and letters
a="True"
print(a)
What is the output?
True
bool
str
Syntax Error
What data type is used to store whole numbers without decimals in programming?
float
double
Int
user Input
Which data type show true or false value?
int
boolean
string
Which data type stores values as True or False?
Boolean (bool)
String (str)
Python If ... Else
while x < 10:
Which one is the example of the data types int?
A
28.02
19
aliya@yahoo.com
What does the term 'Data Type' refer to in programming?
String, integer, or Boolean
Domain
Equals
Logical Operators
