Font size
WorksheetsPython Programming Worksheet
Total questions: 40
Worksheet time: 20mins
What is the first phase in the Python project cycle?
Design
Development
Requirement Analysis
Testing
What activity is commonly done in both the testing and maintenance phases?
Writing user stories
Fixing bugs
Creating diagrams
Writing documentation
Which of the following best defines an algorithm?
A diagram showing steps
A step-by-step procedure for solving a problem
A computer program
A software model
What is a flowchart used for?
Drawing architectural models
Writing code
Visually representing algorithms
Designing databases
In a flowchart, which symbol is used to represent a decision?
Rectangle
Parallelogram
Oval
Diamond
Who developed Python?
Dennis Ritchie
Guido van Rossum
Bjarne Stroustrup
James Gosling
Which of the following is used to output data in Python?
echo()
write()
print()
show()
What is the correct way to create a variable in Python?
var x = 10
int x = 10
x := 10
x = 10
What data type is the result of: type("123")?
int
str
float
bool
Which of the following is NOT a Python data type?
list
tuple
array
dictionary
Python is:
Compiled
Interpreted
Both
None
Which of these is not a core data type?
List
Dictionary
Tuple
Class
What is the output of this code? x = None print(type(x))
Error
String
Bool
NoneType
Which of the following is a mutable data type?
list
tuple
str
int
What will be the result of 3 + 2 * 2?
10
7
9
8
What is the result of bool(0) in Python?
True
False
0
Error
What type of error is raised by the following code? x = 10 print(x / 0)
NameError
TypeError
ValueError
ZeroDivisionError
Which of the following is a valid Python variable name?
1variable
@name
_value
class
What will this code output? a = [1, 2, 3] print(a[3])
3
IndexError
None
4
Which of the following is NOT a keyword in Python?
None
pass
eval
if
Which keyword is used to exit a loop early?
continue
exit
break
stop
What does range(5, 1, -1) generate?
5 4 3 2
5 4 3 2 1
5 3 1
5 1
Which of the following is String literal?
“ABC”
“123”
Both of the above
None of the above
What will be the result of the following command:>>>'I love python'.capitalize()
'I Love Python'
'I love python'
'I LOVE PYTHON'
None of the above
What will be the output of the following command: >>>string= "A quick fox jump over a lazy fox" >>>string.find("fox",9,34)
29
28
8
7
Raman is using string.isspace() in his command, Help him to choose the correct option.
returns True
returns False
Error
None of the above
Find the length of the following string using len( ) : >>>str= “World in Shock.”
14
15
16
17
What will be the output of the following Code: >>>'India is my Country. I love my Country India'.replace("Country", "India")
India is my Country. I love my Country India
Country is my Country. I love my Country Country
'India is my India. I love my India India'
ERROR
Write the correct code for the following output:- Output: 'W O R L D'
>>>str="$" >>>join("WORLD",'$')
>>> "$" = str >>> join("WORLD",'$')
>>>str="$" >>>str.join("WORLD")
>>>str="$" >>> join("WORLD").str
The data type of x in the below code is: txt = "I could eat bananas all day" x = txt.partition("bananas")
string
List
Tuple
Dictionary
The number of element return from the partition function is : >>>"I love to study python".partition("study")
1
3
4
5
Which of the following methods can be used to check if a string ends with a particular suffix.
end()
endswith()
finish()
startswith()
Which operator is used for string concatenation in Python?
*
+
&
%
What will be the result of : "abc123".isalnum()
True
False
Error
None
What does the following return? str1 = "hello" str2 = "HELLO" str1 == str2
True
False
Error
None
What is the output of the following? s = "hello world" print(s.title())
Hello World
Hello world
HELLO WORLD
hello World
What is the output of: print("apple,banana,grape".split(","))
['apple banana grape']
['apple', 'banana', 'grape']
('apple', 'banana', 'grape')
Error
Which of the following list methods is used to delete element from the list?
del( )
delete( )
pop( )
All of these
Suppose list1 is [1, 3, 2]. What is list1 * 2?
[2, 6, 4]
[1, 3, 2, 1, 3, 2]
[1, 3, 1, 3, 2]
[1, 2, 3, 2, 1]
Given the list L=[-1,4,6,-5], write the output of print(L[1:-3])
a)[4,6,-5]
b[ ]
c[6,-5]
d)error
