WILL UPVOTE!! Question 9 2.5 pts Consider the following Python code def fun_AO:
ID: 3915345 • Letter: W
Question
WILL UPVOTE!!
Question 9 2.5 pts Consider the following Python code def fun_AO: print 1 def fun_B0 return 1 Which of the following code will output the value 2? print(fun A)+fun_A0) print(fun_B0 +fun_BO) print fun_A0 +fun_BO) None of the above Question 10 2.5 pts What is wrong with the following? def square(x) returnx print("x is squared") squared-value = square(10) print(squared_value) x2 is not valid. We should use pow(x,2) return x is not valid. We should use print(x) instead return x should not be followed by other statements x must not be modified inside square because it is a parameter of the functionExplanation / Answer
Question 9
2nd option is correct answer, answer is print(fun_B()+fun_B()) it will print 2
Because fun_A() does not return any value it’s just print value 1 when it is called, and fun_B returns value 1 when it is called.
When we use 1st and 3rd options we got an error because the options says addition of two NonTypes in 1st and addition of one NonType and one int Type in 3rd option respectively.
Question 10
Option 3 is correct answer, answer is return x should not be followed by other statements.
Because once a return statement is executed program controller came out of the function and goes back to where the function called from therefore the followed statements after the return statement are not executed.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.