Q. Observe the following programs carefully, and identify the error:


(a)

def create (text, freq):

   for i in range (1, freq):

       print text

create(5) #function call


(b)

from math import sqrt,ceil

def calc():

   print cos(0)

calc() #function call


(c)

mynum = 9

def add9():

    mynum = mynum + 9

    print mynum

add9() #function call

     

(d)

def findValue( vall = 1.1, val2, val3):

      final = (val2 + val3)/ vall

      print(final)

findvalue() #function call


(e)

def greet():

        return("Good morning")

greet() = message #function call


Answer:-

(a)
error at
Create (5) there should be 2 arguments

(b)
Error at
cos( 0) There should math.cos(0)

(c)
Error at
mynum = mynum + 9 because mynum is global variable. So, there should be

global mynum
mynum = mynum + 9

(d)
Error at
findvalue() there should be at least 2 arguments

(e)
Error at
greet() = message #function call

Post a Comment

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

Previous Post Next Post