0% found this document useful (0 votes)
62 views

Functions Program based Question

Uploaded by

suriyaaru08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Functions Program based Question

Uploaded by

suriyaaru08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1.What are the errors in following codes ?

Correct the code and predict


output :
total = 0;
def sum(arg1, arg2):
total = arg1 + arg2;
print("Total :", total)
return total;
sum(10, 20);
print("Total :", total)

2.What are the errors in following codes ? Correct the code and predict
output :
def Tot(Number) #Method to find Total
Sum = 0
for C in Range (1, Number + 1):
Sum += C
RETURN Sum
print (Tot[3]) #Function Calls
print (Tot[6])

3.Find and write the output of the following python code :


def Call(P = 40, Q = 20):
P = P + Q
Q = P - Q
print(P, '@', Q)
return P
R = 200
S = 100
R = Call(R, S)
print(R, '@', S)
S = Call(S)
print(R, '@', S)
4.Consider the following code and write the flow of execution for this. Line
numbers have been given for your reference.

1. def power(b, p):


2. y = b ** p
3. return y
4.
5. def calcSquare(x):
6. a = power(x, 2)
7. return a
8.
9. n = 5
10. result = calcSquare(n)
11. print(result)

5.What will be the output of following program ?


num = 1
def myfunc():
num = 10
return num
print(num)
print(myfunc())
print(num)

6.What will be the output of following program ?


num = 1
def myfunc():
global num
num = 10
return num
print(num)
print(myfunc())
7.What will be the output of following program ?
def display():
print("Hello", end='')
display()
print("there!")

8.Find the errors in code given below :


define check()
N = input ('Enter N: ')
i = 3
answer = 1 + i ** 4 / N
Return answer

9.Find the errors in code given below :


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

10.In the following code, which variables are in the same scope ?
def func1():
a = 1
b = 2

def func2():
c = 3
d = 4
e = 5

You might also like