WorksheetsPython Recap Quiz
Total questions: 120
Worksheet time: 1hrs 5mins
_______ is a data type that contain a set of characters (letters, symbols, etc.) E.g. "Hello", "Ali", "Car Type"
int
float
char
String
Which value is of data type String?
64
"Cat"
True
0.5
What is a Float?
A data type that contains whole numbers. E.g. 3, 45, 124
Numbers with decimal point. E.g. 0.5, 2.45, 56.04
Group of characters between quotation marks. E.g. "Table"
Data type that can only be True or False.
Which value is of data type Float?
64
"Cat"
True
0.5
What is an Integer?
A data type that contains whole numbers. E.g. 3, 45, 124
Numbers with decimal point. E.g. 0.5, 2.45, 56.04
Group of characters between quotation marks. E.g. "Table"
Data type that can only be True or False.
Which value is of data type Integer?
64
"Cat"
True
0.5
What is a Boolean?
A data type that contains whole numbers. E.g. 3, 45, 124
Numbers with decimal point. E.g. 0.5, 2.45, 56.04
Group of characters between quotation marks. E.g. "Table"
Data type that can only be True or False.
Which value is a Boolean?
64
"Cat"
True
0.5
Which of the values below is an integer data type?
1
1.0
1/2
"1"
_____ is a data type that contains a single character such as A, a, Z, z etc.
int
float
char
String
_____ is a data type that can represent one of two values either True or False such as 1, 0, 2 > 1, 3 < 2.
int
float
char
Boolean
Which of the values below is a float data type?
2
2.11
2/4
"2.11"
Which of the values below is a char data type?
firstValue
F
1.0
10 > 3
Which of the values below is a string data type?
firstValue
F
1.0
10 > 3
Which of the values below return TRUE if executed?
10 > 3
10 < 3
10 >< 3
10 <> 3
Which of the values below return FALSE if executed?
10 > 3
10 < 3
10 >< 3
10 <> 3
Which of the values below return FALSE if executed?
1
0
-1
-50
100
"D"
Which of the following is a list data type?
[1, "Hello", 5.0, "World"]
(True, 20)
"Greetings"
200.0
List is a collection which is ordered and changeable.
True
False
What data type is the following?
[70, 80, 90, 100]
Integer
Float
List
String
What is the process of converting one data type to another called?
Data conversion.
Type Casting.
Type Conversion.
Concatenation.
What function converts the data in a variable into a 'integer'?
int()
str()
bool()
float()
What function converts the data in a variable into a 'float'?
int()
flt()
bool()
float()
What function converts the data in a variable into a 'string'?
str()
float()
bool()
string()
What does this built-in function do?
input()
Opens the CD tray.
Prompts the user to enter data.
Displays the word 'input'.
Exits the program.
How do you ask for the user to input their name?
name = int("what is your name")
print("What is your name?")
input = name("what is your name?")
name = input("what is your name?")
By default any data inputted by the user is of data type string in python.
True
False
What will be the output of the following command?
x = int(3.6)
print(x)
3
4
Logical error - Can't cast a float value to an integer as data will be lost.
What will be the output of the following command?
x = float(3)
print(x)
Logical error - Can't cast a integer value to an float as data will be added.
3.0
3
What will be the output of the following command?
x = str(3)
print(x)
3
3.0
'3'
What will be the output of the following program, if the user entered 20 and then 41?
Number1 = input("Enter the first number: ")
Number2 = input("Enter the second number: ")
print(Number1 + Number2)
20 41
Syntax error.
61
2041
What can you add to the following code so that python recognises that they are numbers?
Number1 = input("Enter the first number: ")
Number2 = input("Enter the second number: ")
print(Number1 + Number2)
int()
float()
Use a print statement to tell the user to enter a number.
integer()
Fill in the missing section for the code below:
areaOfSquare = (a) (input("Enter area of square: "))
What will be the output of the following program?
gameOnePoints = 200
gameTwoPoints = "456"
print(gameOnePoints + gameTwoPoints)
Logical error - Can't add an integer and string together.
656
"656"
Enter the missing keyword for the program below:
name =_____("Enter name: ")
input
Bob
Input
What is the name of the built-in command in python to output data?
display
What will be the output for the following python programme:
name = "Dave"
print(name)
What will be the output for the following python programme:
name = "Dave'
print(name)
Syntax error
Name
What is a input?
A built-in function that allows us to prompt the user to enter data.
To plug in something.
Data displayed on a screen.
A device.
What syntax would you use to create a name variable?
name=input()
input=name
name=input{}
name=INPUT
What is the proper syntax for Python comments?
<!-- Python comment -->
<comment> Python comment <comment>
# Python Comment
/* Python Comment */
=
+
==
*
print("Hello world!\nHello world!")
Hello world!
Syntax Error
print("Hello" + str(2) + "world!")
Syntax Error
What does the following code do? myAge = int(myAge)
Converts the variable myAge to a integer
Syntax Error
Converts the variable myAge from a integer to a string
Missing input
print(Hello world!)
Are Double or single quotes used in Python?
Double
Single
Neither
Both work
Which of the following assign the value 50 to a variable x?
x=50
Let x=50
x;=50
x<<50
Python correct naming convention for variables is?
new_user25
NewUser25
25_new_user
25NewUser
NEWUSER25
The output of the program
x = 4
x = "Sally"
print(x)
four
Saly
Sally
4
Print("Hello world!")
Name Error
print("Hello" + 2 + "world")
print("3+4")
print(3+4)
What is the name of the variable in this program?
colour
input
" "
What will be the output for following python programme:
x = 100
y = float(x)
print(y)
200
100.0
100
Can't convert an integer to a floating number.
A named memory location used to store values in computer is a ...
Casting
String
Variable
Hard Drive Disk
Choose three properties of a variable below:
Has a name.
Holds a value.
Has a data type.
Has a length.
Choose variable rules from the list below:
Must not begin with a number
Can only contain (A-Z, a-z) and 0-9 characters, and _
Can use _ to join words separated words
Must be in lower case
In what way is a constant different from a variable?
It can store more than one value
It does not change its value during program execution
Its name should be written in UPPER CASE so it can be easily identified as a constant
The process of giving a value to a variable is ...
Allocation
Assignment
Comparison
Debugging
Choose valid variable names from the list of options given below:
1st_name
Last_name
first Name
f1_name
firstName
Num = 90
Num = 20
print(Num)
90
4.5
20
1800
In the following code, what type of variable is being created?
foo = "bar"
Integer
Float
String
In the following code, what value will be assigned to the variable "cat"?
mouse, cat, dog = "small", "medium", "large"
small, medium, large
small
medium
large
Nothing, that operation will throw an error
In the following code, what value will be assigned to the variable "cat"?
mouse + cat + dog = "small" + "medium" + "large"
small, medium, large
small
medium
large
Nothing, that operation will throw an error
Looking at the following code, what are the names of the variables:
firstName, lastName, fullName
Hyperion, Hub
firstName, lastName, fullName, space
FIRSTNAME, LASTNAME, FULLNAME, SPACE
What rule is the following variable name BREAKING:
1st_Name
No special characters other than underscore
Only use text for the start of the variable name - no numbers at start
Keep names meaningful
There is nothing wrong with this variable name
What rule is the following variable name BREAKING?
StudentNo.
Only use text for the starting letter of a variable name - not numbers at the start
No special symbols other than the underscore
There is nothing wrong with this variable name
Keep variable names meaningful for the task they are being used for
Which name would be meaningful in keeping a record of someone's high score?
s
hs
score
highScore
Which of the below are acceptable variable names?
result final = 5
result-final = 1
resultFinal = 3
result#final = 4
4
3
2
1
3
2
1
0
4
3
2
1
3
2
1
0
4
3
2
1
3
2
1
0
8
6
4
2
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
break
False
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
What does the following comparison operator “==” represent in Python programming?
Equal to
Assignment
Allocation
Not equal to.
What does the following comparison operator “!=” represent in Python programming?
Equal to
Assignment
Allocation
Not equal to.
What does the following comparison operator “>” represent in Python programming?
Equal to
Greater than
Less than
Not equal to.
What does the following comparison operator “<” represent in Python programming?
Equal to
Greater than
Less than
Not equal to.
What does the following comparison operator “>=” represent in Python programming?
Greater than
Greater than or equal to
Greater than and equal to
Less than or equal to
What does the following comparison operator “<=” represent in Python programming?
Greater than
Greater than and equal to
Less than
Less than or equal to
What is the name of the following logical operator?
Returns True if both statements are true
(a)
What is the name of the following logical operator?
Returns True if one of the statements is true
(a)
What is the name of the following logical operator?
Reverses the result, returns False if the result is True
(a)
What is the result of the following condition if x = 3?
not(x < 5 and x < 10)
True
False
What is the result of the following condition if:
A = 30
B = 21
C = 71
(A > B and A > C) or B < C
True
False
What is the result of the following condition if:
A = 30
B = 21
C = 71
not(B < A and B < C)
True
False
What is the result of the following condition if:
A = 30
B = 21
C = 71
B != A or C < A
True
False
Write down the line number in which the first decision is used.
(a)
What would be outputted here?
Bigger than 2!
Number is 5
Bigger than 2!
Number is 5
Nothing
What is the output?
True
False
condition1
condition2
What is the correct syntax for an if statement in Python?
if (condition) {code block}
if condition: code block
if condition then code block
if [condition] {code block}
How do you write an if statement to check if `x` is greater than 10?
if x > 10:
if x is > 10:
if x >> 10:
if x gt 10:
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 will this program output?
:(
":("
Error
nothing
What would be outputted here?
it divides by 7!
it divides by 3!
It divides by 7.
It divides by 3.
What would be outputted here?
WHY!
An error
WHY!!
You have a good taste.
