Q. Find the errors in code given below:
(a)
def minus (total, decrement)
output = total - decrement
print(output)
return (output)
(b)
define check()
N = input ("Enter N: ")
i = 3
answer = 1 + i ** 4 / N
Return answer
(c)
def alpha (n, string ='xyz', k = 10) :
return beta(string)
return n
def beta (string)
return string == str(n)
print(alpha("Valentine's Day") :)
print(beta (string = 'true' ))
print(alpha(n = 5, "Good-bye") :)
Answer =
(a)
def minus (total, decrement):
output = total - decrement
print(output)
return (output)
(b)
def check():
N = int(input ("Enter N: "))
i = 3
answer = 1 + i ** 4 / N
return answer
(c)
Error in following lines :-
1. def beta (string)
2. print(alpha("Valentine's Day") :)
3. print(alpha(n = 5, "Good-bye") :)
So correct code :-
def alpha (n, string ='xyz', k = 10) : return beta(string) return n def beta (string): return string == str(n) print(alpha("Valentine's Day")) print(beta (string = 'true' )) print(alpha(n = 5, "Good-bye"))
I did not understand c partðŸ˜
ReplyDeleteIn first function of C part there are two return statement .
DeleteHello! There's another error in Part B.
ReplyDeleteThe input N is saved a string, the code thus results in 'TypeError' when we try to divide the integer value by N.
Correction: N = int(input("Enter N: "))
Ok, I have corrected it.
DeleteHi
ReplyDeleteYou have not corrected the error in a part. It should be return output (without bracket)
It has no error. return output(with bracket) will also work.
Deletetheres an error you cannot return to beta if you havent defined beta in first place,and in the final alpha call positional should come before keyword
ReplyDelete???
Deletedef alpha (n, string ='xyz', k = 10) :
ReplyDeletereturn beta(string,n)
def beta (string,n):
return string == str(n)
print(alpha("Valentine's Day:"))
print(beta (string = 'true', n=10 ))
print(alpha(n = 5, string="Good-bye:"))
it is the correct program ,3 errors are there in this program
what are the errors
ReplyDeleteHere n is a local value how is it possible for the 2nd function to execute it?
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )