WorksheetsPython
Total questions: 30
Worksheet time: 16mins
Python is a
Object Oriented Programming
Interpreted Programming
High Level Programming
All the Above
Which can be an Identifier among them in Python?
$123
_abc
@fg
1a
What is the data type of print(type(10))
<class 'int'>
int
integer
<class 'integer'>
Predict the Output
x = 'abcd'
for i in x:
print(i.upper())Syntax Error
a B C D
a b c d
A B C D
All keywords in Python are in _________?
Capitalized
Lower case
Upper Case
None of the mentioned
What will be the output of the following Python code?
for i in range(1,5):
if i==4:
continue
print(i)
1 2 3 4 5
1 2 3 5
1 2 3
Error
What is the order of precedence in python?
Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
What is the output of the below code
print("a"+"bc")
bc
abc
aBc
acb
What will be the output of the following Python code?
print("abc. DEF".capitalize())
Abc. def
abc. def
Abc. Def
ABC. DEF
What will be the output of the following Python code?
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)
[1, 4]
[1, 3, 4]
[4, 3]
[1, 3]
What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
print(i)
error
1 2 3 4
a b c d
0 1 2 3
Which of the following is a Python tuple?
{1, 2, 3}
{}
(1, 2, 3)
[1, 2, 3]
Which one of the following is the use of function in python?
Functions are reusable pieces of programs
Functions don’t provide better modularity for your application
All of the mentioned
you can’t also create your own functions
What is output of print(math.pow(3, 2))?
6.0
9.0
9
6
What are the two main types of functions in Python?
System function
Custom function
Built-in function & User defined function
User function
Which of the following code will creates a list?
a = list([1, 2, 3])
a = []
a = list()
all of the mentioned
Suppose list1 is [2, 33, 222, 05, 50], What is list1[-1]
Error
05
50
2
Which arithmetic operators cannot be used with strings
+
-
*
/
Which of the following represents the bitwise XOR operator?
!
^
|
~
What will be the output of the following Python code?
a=[14,52,7]
b=a.copy()
print(b is a)
True
False
0
1
What will be the output of the following Python code?
word1="Apple"
word2="Apple"
list1=[1,2,3]
list2=[1,2,3]
print(word1 is word2)
print(list1 is list2)
True
True
False
True
False
False
True
False
Predict the output str1="helloworld"str1[::-1]
dlrowolleh
hello
world
helloworld
Predict the output
d = {"john":40, "peter":45}
print(list(d.keys()))
[“john”:40, “peter”:45]
[“john”, “peter”]
(“john”, “peter”)
(“john”:40, “peter”:45)
Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?
Raw_input & Input
Input & Scan
Scan & Scanner
Scanner
To open a file c:\scores.txt for writing, we use ____________
outfile = open(“c:\scores.txt”, “w”)
outfile = open(“c:\\scores.txt”, “w”)
outfile = open(file = “c:\scores.txt”, “w”)
outfile = open(file = “c:\\scores.txt”, “w”)
To read the next line of the file from a file object infile, we use ____________
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
What is the data type of
a=(1)
Tuple
Integer
List
Both tuple and integer
Which of these about a dictionary is false?
The values of a dictionary can be accessed using keys
Dictionaries aren’t ordered
Dictionaries are mutable
The keys of a dictionary can be accessed using values
What is the output of the following if statement
a, b = 12, 5
if a + b:
print('TRUE')
else:
print('False')
True
False
Error
TRUE
What is the output of the following Code
aList = [4, 8, 12, 16]
aList[1:4] = [20, 24, 28]
print(aList)
[4, 20, 24, 28, 8, 12, 16]
[4, 20, 24, 28]
[20,24,28,12,16]
[4,20,24,28,16]
