Computer Science
Find the errors in following function definitions :
- 1.
def main()
print ("hello")
- 2.
def func2():
print(2 + 3)
- 3.
def compute():
print (x * x)
- 4.
square (a)
return a * a
Python Functions
2 Likes
Answer
- Colon is missing at the end of function header.
- There is no error.
- The variable
x
is not defined. def
keyword at the beginning and colon at the end of function header are missing.
The corrected function definitions are:
- 1.
def main():
print("hello")
- 2.
def func2():
print(2 + 3)
- 3.
def compute(x):
print (x * x)
- 4.
def square(a):
return a * a
Answered By
3 Likes
Related Questions
Which of the following keywords marks the beginning of the function block?
- func
- define
- def
- function
What is the area of memory called, which stores the parameters and local variables of a function call ?
- a heap
- storage area
- a stack
- an array
What is the default return value for a function that does not return any value explicitly ?
- None
- int
- double
- null
Which of the following items are present in the function header ?
- function name only
- both function name and parameter list
- parameter list only
- return value