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"))

11 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. I did not understand c part😭

    ReplyDelete
    Replies
    1. In first function of C part there are two return statement .

      Delete
  2. Hello! There's another error in Part B.
    The 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: "))

    ReplyDelete
  3. Hi
    You have not corrected the error in a part. It should be return output (without bracket)

    ReplyDelete
    Replies
    1. It has no error. return output(with bracket) will also work.

      Delete
  4. theres 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
  5. def alpha (n, string ='xyz', k = 10) :
    return 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


    ReplyDelete
  6. what are the errors

    ReplyDelete
  7. Here n is a local value how is it possible for the 2nd function to execute it?

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post