Question: Q 1 : In the code, we are calling two functions, greet ( ) and say _ goodbye ( ) . - The greet (
Q: In the code, we are calling two functions, greet and saygoodbye
The greet function is already defined but it has a bug. It should print "Hello, World!".
The saygoodbye function is not defined. Define it so that it prints "Goodbye, World!".
def greet:
printHello World!"
# don't modify below this line
greet
saygoodbye
Q: There is a bug in the code below. Can you fix it so that the output is:
printnumber
printnumber
def printnumberk:
printk
Q: n the code, define a function called farewell, which takes a single parameter. The function should print "Goodbye, followed by the parameter. Then use this function so that the output is:
Goodbye, Bob
Goodbye, Charlie
Goodbye, Lisa
# don't modify below this line
farewellLisa
Q: In the code, define two functions, twosum, and threesum. The twosum function should take two parameters and print their sum. The threesum function should take three parameters and print their sum.
Finally, call twosum with the arguments and after that call threesum with the arguments
# do not modify below this line
twosum
threesum
Q: In the code create a function named product that accepts two parameters and returns their product.
# don't modify below this line
printproduct
printproduct
printproduct
printproduct
Q: In the code, call the function greet with the argument "Lisa". Then print the type of the return value of the function.
Hint: You can get the type of a value with the type function.
def greetname :
printHello name
Q: To prove that the variable k inside the function is different than the one outside, consider this code:
def addonek:
k k
printk
k
addonek # Output:
printk # Output:
What do you think the output of the last print statement will be Will it be or Run the code to find out.
Q: There's a bug in the code below, if you try to run it you'll see a NameError. Can you fix it so that the output is:
k
def printlocalvariablenum :
printnum
printlocalvariablek
printnum
Q: In the code below, update the function greet so that the second parameter has a default value of
def greetname punctuation :
printHello name punctuation
greetWorld
greetWorld
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
