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

slip test - functions error based

CBSE CLASS 12 WORKING WITH FUNCTIONS QUESTION PAPER

Uploaded by

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

slip test - functions error based

CBSE CLASS 12 WORKING WITH FUNCTIONS QUESTION PAPER

Uploaded by

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

OXALISS INTERNATIONAL SCHOOL (CBSE), THATCHUR.

Computer Science (083)


Class: XII Session: 2024-25
SLIP TEST – WORKING WITH FUNCTIONS
Date : 23.07.2024 Max. Marks: 10
ANSWER KEY
SECTION – A
Observe the following Python code very carefully and rewrite it after removing all syntactical
errors with each correction underlined.
1. DEF execmain(): 2
x = input("Enter a number:")
if (abs(x)=x):
print ("You entered a positive number")
else:
x=*‐1
print "Number made positive:"x
execmain()
Ans.
:

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

Reason:

 There is an indentation error in second line.


 The return statement should be indented inside function and it should not end
with semicolon.
 Function call should not end with semicolon.
3. def sum(c) 2
s=0
for I in Range(1,c+1)
s=s+i
return s
print(sum(5)
Ans.
:

4. Rao has written a code to input a number and check whether it is prime or not. His code 2
is having errors. Rewrite the correct code and underline the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
Ans.
:

5. Atharva is a Python programmer working on a program to find and return the maximum 2
value from the list. The code written below has syntactical errors. Rewrite the correct
code and underline the corrections made.
def max_num (L):
max=L(0)
for a in L :
if a > max
max=a
return max
Ans. def max_num(L):
: max = L[0] # Correction: used square brackets to access the first element.
for a in L:
if a > max: # Correction: added a colon at the end of the 'if' line.
max = a
return max

You might also like