Font size
WorksheetsPython with Functions
Total questions: 50
Worksheet time: 26mins
print(3+4)
3+4
7
SyntaxError
print(3+4)
What would this print?
print("3+4")
Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
What will be the value of the following Python expression?
4 + 3 % 5
a) 7
b) 2
c) 4
d) 1
Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Which of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
Which of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
What is the output of the given code?
10 20 10 20
10 20 10
10 20 20
Error
To add a new element to a list we use which Python command?
a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)
What will be the output of the following Python statement?
>>>"abcd"[2:]
a) a
b) ab
c) cd
d) dc
What will be the output of the “hello” +1+2+3?
a) hello123
b) hello
c) Error
d) hello6
chose which is a floating point
14
15.5
chose a string
"tim"
"tim
'tim'
"tim
tim
where is python used
web aplications
data science
mobile apps
GUI applications
Which is the correct operator for power xy
x^y
x**y
x^^y
None of these
A Python dictionary stores ...
value - key pairs
key - value pairs
Which of the following create an empty dictionary (D)?
D = dict()
D = ()
D = []
D = {}
quiz = ("Do you help out at home? ":"yes" }
Which method will remove an element the Dictionary data type?
.pop()
.discard()
.remove()
Lists use _____ to access values
values
indexes
key values
keys
Consider this list, what will be the highest index the list can have:
li=[1,2,3,4,5]
2
3
4
5
Consider this list, what will be the output of the following:
li=[1,2,3,4,3,2,1]
print(li[-3])
4
3
2
1
__________ keyword is used for creating a function in Python.
define
fun
def
function
Each item in a list has an index. What is the first index in a Python list?
0
1
a
A
What will be the output of this program?
def hello():
print(“I am a beginner”)
hello()
hello()
I am a beginner
I am a beginner I am a beginner
Hello
Hello
Hello
I am a beginner
I am a beginner
What is the output of the given code?
10 20 10
10
20
10 20
The default return value of any function in Python is _______________.
null
0
None
Garbage value
__________ is the built-in function to know the type of a variable or function.
id()
type()
data_type()
none of the above
times is ________________ type of argument.
default arguments
keyword arguments
positional arguments
arbitrary positional arguments
arbitrary keyword arguments
Select the advantages of functions
Modular programming
Code re-usability
Improving clarity of the code
All the above
One of the following functions is not used with Python String
Split
Remove
Replace
Choose the correct syntax of the split function:
x.split[]
split(x)
x.split(",", 3)
X.SPLIT(",", 3)
Choose the correct syntax of the replace function:
x.Replace(x)
x.replace(y)
x.replace(3,x)
x.replace("j","3")
Choose the correct code to print line of 10 stars using repetition operation:
print("**********")
print("*"*10)
print("*"^10)
print("*"+10)
The correct syntax of the len function for string x:
x.len()
len[x]
LEN[]
len(x)
The correct syntax for converting the string x to uppercase is :
X.upper()
upper(x)
x.UPPER[ ]
x.upper()
The correct syntax for converting the string myname to lowercase is :
myNAME.lower[ ]
myname.lower( )
myname.upper( )
myname_lower(12 )
To remove the spaces present at start and end of the string, you can use
split()
len()
strip()
remove()
Let x= "Python", the output of print(x.upper()) is
python
PYTHON
_PYTHON
"PYTHON"
str1='101'
x=int(str1)
z=x+400
print(z)
101400
x400
501
none of above
What is the purpose of a function?
They are reusable pieces of programs.
They are required by the Python
They allow us to compile our program
They make the program larger
