NEW
Font size
WorksheetsPython Quiz
Total questions: 20
Worksheet time: 10mins
What is a correct syntax to output "Hello World" in Python?
Print("Hello World")
P "Hello World"
p ("Hello World")
Print["Hello World"]
Lists are used to store single item in a single variable.
True
False
List items are indexed, the first item has index [1], the second item has index [2] etc.
True
False
If you add new items to a list, the new items will be placed at the end of the list.
True
False
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
nameList["4"]
What is the index of “grape” in the list
[“apple”, “grape”, “orange”, “watermelon”]?
0
1
2
3
If the list of vegetables is defined as:
vegetables = ["Potato", "Cucumber", "Lemon", "Tomato"]
Then what is the output of the following statements?
del vegetables[2]
print(vegetables)
['Ptato', 'Cucumber', 'Tomato']
['Ptato', 'Cucumber', 'Lemon', 'Tomato']
None of these
Which loop is used when you know the exact number of repetitions?
While Loop
For Loop
Repeat Loop
Which loop is known as condition-controlled loop?
While
For
None of these
The position of an element in the list in known as _________
List
Index
Value
What is the purpose of this program?
games = ["cricket", "hockey", "tennis"]
games[0] = "football"
hockey will be replaced with football
football will be added in the list
hockey will be removed
Which function is used to find the length of a list?
Print( )
Input( )
len( )
If the list has 5 elements, the index numbers go from --------
0 to 4
1 to 4
1 to 5
A program which does not crash is known as -----------
Robust Program
Strong Program
Weak Program
Validation is used to --------------
Allow bad input
Block bad input
None of these
If structure begins with ----------
A logical test
Bracket
Both of these
If the test is true in if...else, it means to -------
show an error
carry out the command
Both of these
Which of the following will ask you to input until the value matches the requirements of the program?
For Loop
If....else
While Loop
None of these
What will be the output of these commands?
value = len("Python")
print(value)
6
5
4
2
