Q16. What is a function?

Ans: Function is a collection of statements, which is defined once and then call it later to do some executions. Below is the function definition example

def total_course_durations(c1,c2):

    training=curse_duration()

    training.hours=c1.hours+c2.hours

    training.minutes=c1.minutes+c2.minutes

    training.seconds=c1.seconds+c2.seconds

    return training

 

total_duration=total_course_durations(hadoop_training,spark_training)

 

 

Name of the function: total_course_duration

Statements: All orange color lines are statements.

return: It is a return statements.

total_duration: It is a variable, holding the values return by function call.

Function Arguments: These two variables are known as function arguments hadoop_training,spark_training

 

Q17. How do you convert data from one data type to another data types?

Ans: There are various functions available, which can help you convert data from one data types to another data type. See the example below

int(‘100’) -> 100 #Converting string to int

flaot(‘100.5’) -> 100.5 #Converting string to float

str(3.02) -> ‘3.02’ #Converting float to string

 

Q18. What is the module in Python?

Ans: Python module is any python file with .py extension, which contains functions and variables are known as Python Module. To use module in our current program we have to import it first. There are in-built modules which are provided by Python itself e.g. import math (Here, math is a Python module) 

 

Q19. What do you mean by a fruitful functions?

Ans: Function, which return a value is known as fruitful function. E.g math.sqrt(4), it will return 2

 

Q20. What is void function?

Ans: Function which does not return a value is known as void function.

Why Dont you prepare for Python Certifications and Interview Questions with 250+ Questions and Answer : Check Here

Real Exam Number of Questions: 70 Questions
Real Exam Pass Score: 70%
Time Allotted: 90 minutes to complete exam