in pyton
Looking at the following function definition:
def my_function(a,b,c):
d = (a + c) / b
print(d)
return
Write a statement which calls this function using KEYWORD ARGUMENTS to pass 2 into a, 4 into b and 6 into c.
# do comment if any problem arises
# Code
def my_function(a, b, c):
d = (a + c) / b
print(d)
return
# using keyword arguments first a=2 then c=6 and b=4
my_function(a=2, c=6, b=4)
Screenshot:

Output:

in pyton Looking at the following function definition: def my_function(a,b,c): d = (a + c) /...
Look at the following function definition: def my_function(x, y): return x[y] a. Write a statement that calls this function and uses keyword arguments to pass ‘testing’ into x and 2 into y. b. What will be printed when the function call executes? 6. Write a statement that generates a random number in the range I'm using python to solve this this is what i did def main(): result= my_function(x='testing', y=2) print(result) def my_function(x,y): return x[y] main()
##8. A program contains the following function definition: ##def cube(num): ##return num * num * num ##Write a statement that passes the value 4 to this function and assigns its return value ##to the variable result. ##9. Write a function named times_ten that accepts a number as an argument. When the ##function is called, it should return the value of its argument multiplied times 10. ##10. Write a function named is_valid_length that accepts a string and an integer as ##arguments....
in python 3 1. A program contains the following function definition: def cube(num): return num * num * num Write a statement that passes the value 4 to this function and assign its return value to the variable result. 2. Write a function named get_first_name that asks the user to enter his or her first name and returns it.
In the following function definition, what do we call ans? def show_cube_root(x): ans = x ** (1.0/3.0) print('The cube root of ' + format(x, '.3f') + ' is ' \ + format(ans, '.3f') + '.') a global variable a local variable a parameter a keyword
Which of the following programs defines and calls a function to compute and print the cube of "2"? (There could be more than one correct answer.) def cube(n): return n * n * n print(cube(2)) def cube(n): return n ** 3 print(8) def cube(a): b = a * a return b * a c = 2 d = cube(c) print(d) def cube(n): n ** 3 print(cube(2))
1. Write a statement that calls a function named showSquare, passing the value 10 as an argument. 2. Write the function prototype for a function called showSquare. The function should have a single parameter variable of the int data type and areturn type of void. 3. Write the function prototype for a function called showScoreswith a parameter list containing four integer variables and a return type of void. 4. Look at the following function definition: double getGrossPay(int hoursWorked, double payRate)...
The programs for this week will all take the form: def main(): collect the input for the arguments value = functionName(arguments) print(value) def functionName(arguments): code to solve the problem return value main() Write programs using functions to solve: • Write the following functions and provide a program to test them. Include descriptive statements that prompt the user for the the three input variables. b. def average(x, y, z) (returning th average of the arguments)
Consider the following Python program: def fun(x, y): return x + y # [2] # [1] a = fun(2, 3) b = fun("2", 3) print a, b What does it evaluate to? Replace the last statement print a, b with print a + b and explain the traceback. What's wrong? Now eliminate the line marked [1] and change line [2] to read return x + y. Run the program and explain the traceback. Consider the following definition: def fun(n, m):...
In Python: Write the definition for a function named avg which accepts two int parameters, and returns the average of the two values Write a statement that calls this function to print out the average of values 11 and 25.
Your task is to: 1. Introduce function documentation (the triple-quoted string that precedes the definition of a Python function) 2. Make sundry changes to improve the readability of the code. This might include: 1. Be sure to change the function names to something appropriate. 2. If there are any "gotchas" or assumptions about the input, document those. 3. If the variables are poorly named, change the variable names. 4. If the logic is needlessly complicated or redundant, abbreviate it. 3....