QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A CBSE12A-2015-B01C #6340

Question:

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

def Sum(Count) #Method to find sum
    S=0
    for I in Range(1,Count+1):
        S+=I
    RETURN S
print Sum[2] #Function Call
print Sum[5]

Answer:

def Sum(Count) : #Method to find sum   #Error 1
    S=0
    for I in range (1,Count+1):        #Error 2
        S+=I
    return S                           #Error 3
print Sum (2) #Function Call           #Error 4
print Sum (5)                          #Error 4