NEW
Font size
WorksheetsPYTHON QUIZ
Total questions: 20
Worksheet time: 12mins
holds whole numbers
holds a decimal point in a number
Which of the following is used in Python to calculate ten squared?
print("3+4")
Gjdk is not a good name for a variable, why?
It starts with a capital letter.
It does not contain any spaces.
There are no vowels.
It's meaningless.
Variable names can start with...
...only capital letters.
...any number, letter or an underscore (_).
...any letter or symbol.
...any letter or an underscore (_).
You are asked to write a program where the user types in the amount of marks they got for a paper with 70 marks. The program then calculates and displays their score as a percentage. What is the process?
marks (integer)
percentage (float)
percentage = marks/100*70
percentage = marks/70*100
Guess the output:
a = 255
b = 255
print(a == b)
True
False
If you want to create an empty list called colours in Python, which of the following is correct?
colours = [ ]
colours = ( )
colours = { }
colours = <>
What letter will be printed on the screen after running this code:
n
e
a
Nothing prints
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Mac, Donald, Colonel, Tony
nameList = ("John", "Harry", "Mac", "Donald", "Colonel", "Tony")
nameList = ["John", "Harry", "Mac", "Donald", "Colonel", "Tony"]
nameList = [John, Harry, Mac, Donald, Colonel, Tony]
List items have an index number. In the following list, which item has the index number of 3?
["John", "Harry", "Mac", "Donald", "Colonel", "Tony"]
"Tony"
"Harry"
"Mac"
"Donald"
The list needs one more name added to the end - "Stark". Which piece of code below would do this?
nameList = ["John", "Harry", "Mac", "Donald", "Colonel", "Tony"]
nameList.append(Stark)
append(nameList,"Stark")
nameList.append["Stark",7]
nameList.append("Stark")
What will be the output?
tuple1=['sam', "Pam", 12,44]
print(type(tuple1))
<class 'list'>
<class 'tuple'>
