0% found this document useful (0 votes)
53 views3 pages

Function MCQ

The document provides a comprehensive overview of functions in programming, particularly in Python, covering definitions, syntax, and characteristics. It addresses key concepts such as modular programming, function calls, parameters, and the advantages of using functions. Additionally, it includes examples and questions related to string manipulation and function documentation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views3 pages

Function MCQ

The document provides a comprehensive overview of functions in programming, particularly in Python, covering definitions, syntax, and characteristics. It addresses key concepts such as modular programming, function calls, parameters, and the advantages of using functions. Additionally, it includes examples and questions related to string manipulation and function documentation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Functions

1.What is the process of dividing a computer program into separate independent blocks of
code known as?
➢ Modular programming.
2. What is the purpose of functions in programming?
➢ To achieve modularity and reusability.
3. Which of the following statements is true about functions?
➢ Functions can be called repeatedly.
4. What is the syntax to define a function in python?
➢ Def function_name():
5. What does the written statement do in a function?
➢ Ends the function execution and optionally passes back and expression to the
caller.
6. What is the term for a value passed to a function during function call?
➢ Argument.
7. What is the user defined function?
➢ A function defined by the programmer.
8. In the function definition`def add (a,b):`, what are `a`and`b`?
➢ Parameters.
9. Which keyword is used to create a function in python?
➢ Def.
10. What is the hot put for the following code?
Python code:
def greet(name):
return “Hello,”+name
print(greet(“Alice”))
➢ Hello,Alice

11. How do you call a function named`my_function` in python?


➢ My_function()
12. What will be the output for the following code?
Python code:
Def add(a,b):
Return a+b

result =add(3,5)
print(result)
➢ 8
13.What is the advantage of using functions in a program?
➢ Increases reusability.
14.Which of the following is not a characteristic of a function?
➢ it must return a value.
15. What is the main advantage of breaking the program into smaller functions?
➢ To make the program organized and manageable.
16. What is the keyword used to return a value from a function in a python?
➢ Return.
17. Which of the following is best describes of function?
➢ A block of code that perform a specific task.
18. How do you define a function with no parameters?
➢ Def function_name():
19. What is the function call?
➢ Executing a function.
20. Which of the following is an invalid function name in python?
➢ 1function.
21. what is the purpose of the`def function in python?
➢ To define a function.
22. What is a parameter in the context of a functions?
➢ Variable used in the python definition.
23. How do you pass multiple arguments to function in python?
➢ def function_name(arg1,arg2).
24. What is the main purpose of using functions in programming?
➢ To organize code and promote reusability.
25. what is the keyword used to define a function in python?
➢ def.
26. How do you specify default to values for parameters in a function?
➢ Def function_name(parameters=value):
27. Which statement is true regarding a function with multiple returns statements?
➢ Only the first return statement will be executed.
28. Which of the following is a correct way to document a function in a python?
➢ Using triple quote strings (‘’’’’’’ ‘’’’’’)
29. What is the term used for a function defined inside another function?
➢ Nested function.
30. How do you ensure a function as a variable number of arguments in python?
➢ Using an asterisk (*) before the parameter name.
31. Which of the following is not valid python function?
➢ def my-func():

8.STRINGS
1. What is the output of`str1[::-1]`if`str1 = ‘Hello World!’`?
➢ `
2. What is the result of`str1[1:5]`if`str1= ‘Hello World!’`?
➢ B
3. Which of the following methods returns with the first letter of every word in uppercase
and the rest in lowercase?
➢ C.
4. which function audio choose to find the length of a string`str1`?
➢ A
5.

You might also like