Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing inEnroll Now
Some of the built-in functions we have seen require arguments. For example,
math.cosyou pass a number as an argument.
math.powtakes two arguments, the base and the exponent to calculate the exponential of some number.
Inside the function, the arguments are assigned to variables called parameters. Here is an example of a user-defined function that takes an argument:
def print_name(value): x = value print(value)
This function assigns the argument to a parameter named
value. When the function is called, it assigns the value to x and then prints the value of the parameter (whatever it is).
The same rules of composition that apply to built-in functions also apply to user-defined functions, so we can use any kind of expression as an argument for
The argument is evaluated before the function is called, so in the above example,
str(math.cos(0)) is evaluated only once.
Write a function with name
my_function which takes one argument with name
number. Then, inside the function, write these statements,
1 - Store the
number in a variable
2 - Convert it into
str and store it in
3 - Concatenate
4 - print
Test your function by passing an argument
10. It should print
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here