Python Quiz on Functions, Built-in Functions & Function arguments
Functions are an integral part of any programming language as they promote code reuse and provide modularity to the code. We have plenty of built-in functions and we can create user functions as well.
Let us now check our knowledge of functions in Python with the quiz. All the best!
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
- Question 1 of 15
1. Question
How many arguments can be given to a single function?
CorrectIncorrect - Question 2 of 15
2. Question
Which of the following is the keyword to create user-defined functions?
CorrectIncorrect - Question 3 of 15
3. Question
Which of the following is not a built-in function in python?
CorrectIncorrect - Question 4 of 15
4. Question
How do we write arbitrary arguments while defining a function?
CorrectIncorrect - Question 5 of 15
5. Question
When we pass arguments to a function having arbitrary arguments how is the data sent to the function?
CorrectIncorrect - Question 6 of 15
6. Question
Find the output of the code given below?
# Code snippet starts
l = [107,542,239,789,12,10]
ans = l[0]
del l[3]
for i in range(1,len(l)):
ans = max(ans,l[i])
print(ans)
# Code snippet ends
CorrectIncorrect - Question 7 of 15
7. Question
Which type of arguments are being used in the code given below?
# Code snippet starts
def funcSquare(*num):
for i in num:
print(i*i,end=” “)
funcSquare(1,7,3,4,2)
# Code snippet ends
CorrectIncorrect - Question 8 of 15
8. Question
Find the output of the code given below?
# Code snippet starts
def funcGreet(text= “Good Morning ” , name):
print(text,name+”!”)
funcGreet(“John”)
# Code snippet ends
CorrectIncorrect - Question 9 of 15
9. Question
Which type of function is used in the code given below?
# Code snippet starts
sqNum = lambda x: x * 2
print(sqNum(12))
# Code snippet ends
CorrectIncorrect - Question 10 of 15
10. Question
How many function calls are being made in the code given below?
# Code snippet start
import math
def sqr(a):
return a*a
def root(a):
return math.sqrt(a)
def calc(a):
l = []
l.append(sqr(a))
l.append(root(a))
return l
print(calc(5))
# Code snippet end
CorrectIncorrect - Question 11 of 15
11. Question
How many arguments can the greet function take?
# Code snippet starts
def greet(* names):
res = []
for name in names:
res.append(“Hello, “+name)
return res
print(greet(“John”,’Tom’,’Anie’,’rosy’))
# Code snippet end
CorrectIncorrect - Question 12 of 15
12. Question
How many functions are being used in the code given below?
# Code snippet starts
num = 34
num2 = 105
print(chr(num2))
# Code snippet end
CorrectIncorrect - Question 13 of 15
13. Question
Find the output of the code given below?
# Code snippet starts
org = ‘ QuizOrbit ‘
def calcScore(org):
res = 0
for ele in org:
res+=ord(ele)
return res
print(calcScore(org))
# Code snippet end
CorrectIncorrect - Question 14 of 15
14. Question
Find the output of the code given below?
# Code snippet starts
import math
def sqr(a):
return a*a
def cube(a):
return str(type(a**3))
def log(a):
return math.log(a)
def calculationTypes(a):
l = ”
l += str(sqr(3))+ cube(1)[0] + str(int(2*log(a)))
return l
print(calculationTypes(10))
# Code snippet end
CorrectIncorrect - Question 15 of 15
15. Question
Find the output of the code given below?
# Code snippet starts
import math
def sqr(a):
return a*a
def root(a):
return math.sqrt(a)
def calc(a):
l = []
l.append(sqr(a))
l.append(int(root(a)))
return l[1]
print(calc(5))
# Code snippet end
CorrectIncorrect
Summary
Functions are one of the major tools of any programmer. They help us to enhance code quality and promote code reusability. With the quiz, you might have understood your knowledge of functions and arguments as well. Any good programmer won’t move ahead until he clearly understands this topic.
Happy Learning!
how q.10 become None of these please explain
Explain the q.13 how it comes 1001 . Wrong ans how tehe correct ass will be 969. Option is not available.
Variable Initialization:
org = ‘ QuizOrbit ‘: Initializes a string variable org with the value ‘ QuizOrbit ‘.
Function Definition (calcScore):
def calcScore(org):: Defines a function named calcScore that takes a string parameter org.
Variable Initialization (res):
res = 0: Initializes an integer variable res with the value 0. This variable will be used to accumulate the sum of ASCII values.
For Loop (for ele in org):
for ele in org:: Iterates over each character (ele) in the string org.
res += ord(ele): Adds the ASCII value of the current character ele to the variable res.
Return Statement (return res):
return res: Returns the final sum of ASCII values calculated in the calcScore function.
Function Call (print(calcScore(org))):
Calls the calcScore function with the argument org and prints the result.
Explanation:
The program calculates the sum of ASCII values of all characters in the string org.
The ASCII value of a character is obtained using the ord() function.
The for loop iterates over each character in the string, and the ASCII value of each character is added to the variable res.
The final sum of ASCII values is returned by the calcScore function and printed.
Output:
For the given string ‘ QuizOrbit ‘, the ASCII values are calculated as follows:
scss
Copy code
32 (space) + 81 + 117 + 105 + 122 + 79 + 114 + 98 + 105 + 116 + 32 (space)
Summing these values: 32 + 81 + 117 + 105 + 122 + 79 + 114 + 98 + 105 + 116 + 32 = 1039
So, the output of the program will be 1039, which is not present in option