Font size
WorksheetsFundamental Python
Total questions: 76
Worksheet time: 38mins
Is Python case sensitive when dealing with identifiers?
Yes
No
Mathematical operations can be performed on a string.
True
False
Which of the following has the highest precedence in the expression?
Addition
Exponential
Multiplication
Parentheses
Which of the following data types is not supported in Python?
String
Numbers
Slice
List
Which one of the following is NOT a Python's predefined data type?
List
Dictionary
Tuple
Class
Which of the following has more precedance?
/
+
()
-
Choose the INVALID identifiers from the following
NUmbEr1
1NUMBer
A_B
A&B
Examples of String Literals
"ABC1273"
nfjdlsj@@$
12638
'7e920938'
Escape sequence is represented by a ____ followed by one or more characters
Front slash
Double Quote
Single Quote
Back Slash
Size of the string "Ant Man"
(a)
str="Red\
block\
a"
Size of str is 11. True/False ?
True
False
Select the valid Octal integer literals
0836
7976
07362
0x1726
An escape sequence represents how many characters ?
"\t"
3
2
1
4
Which of the following is a Boolean literal ?
True
false
False
true
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
It displays an output
What is the output from the following code?
print ("hello world")
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"]
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)
nameList["4"]
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
The list will be slice and show Harry and Jesse only. Which piece of code below would do this?
print(nameList[1:3])
print(nameList[0:1])
print(nameList[1:2])
print(nameList["Harry":"Jesse"])
To insert an the string "Pedro" in the first position of a the nameList we use
nameList.append("Pedro, 1")
nameList.insert("Pedro",0)
nameList.insert(1, "Pedro")
nameList.insert(0, "Pedro")
variable.sort() will do what?
Sort the list into alphabetical order
Sort the list into reverse order
Create a new list
Error
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
del nameList[3]
print(nameList)
What would be the output
['John', 'Harry', 'Jesse', 'Marry', 'Larry']
['John', 'Harry', 'Jesse', 'John', 'Larry']
['John', 'Harry', 'John', 'Marry', 'Larry']
Error
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
print(nameList.count("John"))
What would be the output
1
2
3
Error
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
nameList[6] ="Susie"
print(nameList)
What would be the output
['John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry', 'Susie']
['Susie', 'John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry']
['Susie']
Error
Is this the correct code for a list?
register = {"Sam", "Pheobe", Georgia", Richard"}
Yes
No
Output of this code?
[2,4,6,8,10]
['2','4','6','8','10']
[0,2,4,6,8]
[10,8,6,4,2]
What is the index of “grape” in the list
[“apple”, “grape”, “orange”, “watermelon”]?
0
1
2
3
mylist = ["a","b"]
mylist[1] = "c"'
print(mylist)
["a","c"]
["a","b"]
["a","b","c"]
mylist
Tuples in Python are mutable
False
True
CAN A VALUE IN A TUPLE BE EDITED?
YES, IT CAN BE DONE JUST AS WE DO WITH LISTS
NO, TUPLE IS AN IMMUTABLE DATA TYPE
Dictionary keys must be immutable
True
False
________________method removes all items from the particular dictionary.
clear( )
pop( )
del ( )
_______________this method deletes the item from the dictionary
pop( )
del( )
clear( )
A collection of objects which ordered, immutable, and allows duplicate values.
Tuple
Sets
Module
Dictionary
A collection that is unordered, changeable, and does not allow duplicates.
Tuple
Sets
Module
Dictionary
A collection which is unordered and unindexed.
Tuple
Sets
Module
Dictionary
It is simply a file containing python code, it may contain functions, classes, etc.
Tuple
Sets
Module
Dictionary
Which symbol surrounds a tuple?
Which symbol surrounds a Sets?
Which operator is used to concatenate?
+
-
/
*
It returns an item from the tuple with a max value.
max(t)
min(t)
It returns an item from the tuple with a min value.
max(t)
min(t)
How to create a single element tuple
(1,)
(1)
{1}
[1]
tuple([1])
Result of the program above is
('1', '2', '3', '4', '5')
(1, 2, 3, 4, 5)
12345
"12345"
What is the output of the program above
<class 'tuple'>
<class 'None'>
<class 'list'>
<class 'int'>
Which of the following is true
a is assigned a value of 1
b is assigned a value of [2,3]
b is assigned a value of (2,3)
b is assigned a value of 2
What is the output of the code above ?
1 4
1
1 None
1 [2,3,4]
1 (2,3,4)
What is the output of the program above ?
True
False
Yes
In a Python program , a control structure:
directs the order of execution of the statements in the program
dictates what happens before te program starts and after it terminates
defines program-specific data structures
manages the input and output of control characters
What is the output of the above program ?
Am I here?
Or here ?
Am I here ? Or here ?
Or here ? Or over here ?
If the user inputs : 2<Enter> , what does the following code snippet print ?
Yes
No
May be
Nothing printed
Error
Function range(3) is equivalent to "
range(1,3)
range(0,3)
range(0,3,1)
range(1,3,0)
Consider the following loop given below :
for i in range(5):
print(i)
How many times will this loop run ?
5
0
infinite
Error
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
more than 7
more than 23
spam
7
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
An If statement can be executed multiple times
FALSE
TRUE
The ‘else’ statement is optional in Python
TRUE
FALSE
It is possible to execute both the statements under if and else at the same time.
TRUE
FALSE
There can be an else statement without an if statement
FALSE
TRUE
The relational operators cannot be used within a if condition
FALSE
TRUE
The program generates an error message if the "else" statement is not defined
FALSE
TRUE
What is the output?
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
What is the output if the user types "Python"?
guess=input()
guess=input()
guess=input()
guess=input()
