WorksheetsPython data types
Total questions: 15
Worksheet time: 8mins
Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do?
x = x + 2
This would fail as it is a syntax error
Produce the value "false" because "x" can never equal "x+2"
Retrieve the current value for x, add two to it and put the sum back into x
Create a function called "x" and put the value 2 in the function
What will be the value of x after the following statement executes:
x = 1 + 2 * 3 - 8 / 4
5.0
4
15
3.0
Which of the following elements of a mathematical expression in Python is evaluated first?
*
/
()
+
Which of the following is not a Python reserved word?
iterate
continue
break
else
Which of the following is a bad Python variable name?
Spam
_spam
23spam
SPAM23
Which character represents a comment in Python code?
*
#
&
$
What is the Python code needed to ask a user for input?
input("what is your name?")
input="what is your name?"
(input)=what is your name?
input=what is your name?
Which is the operator used to FIND THE REMAINDER OF DIVIDING?
+
*
/
%
Which is the operator used to MULTIPLY?
+
*
/
-
%
Which of the following data types can consist of numbers, alphabets and symbols?
String
Integer
Float
Boolean
What will be the output from the following Python code?
print("3+4")
7
3+4
34
SyntaxError
What will the output be from the following Python code?
print(3+4)
3+4
7
SyntaxError
print(3+4)
What is the output of the following Python code?
print('Hello' + "world!")
Helloworld!
Hello world!
'Hello' "world!"
Error message
What is an Integer?
A data type that contains whole numbers. eg: 3, 45, 124
Numbers with decimal point. eg: 0.5, 2.45, 56.04
Group of characters between quotation marks. eg: "dog"
Data type that can only be True or False.
What is a String?
A data type that contains whole numbers. eg: 3, 45, 124
Numbers with decimal point. eg: 0.5, 2.45, 56.04
Group of characters between quotation marks. eg: "dog"
Data type that can only be True or False.
