QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A CBSE12D-2015-B01C #6509

Question:

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

def Tot(Number) #Method to find Total
    Sum=0
    for C in Range (l, Number+l):
        Sum+=C
RETURN Sum

print Tot[3]    #Function Calls
print Tot[6]

Answer:

def Tot(Number) : #Method to find Total   #Error 1
    Sum=0
    for C in range (1, Number+1):         #Error 2
        Sum+=C
    return Sum                            #Error 3
print Tot (3) #Function Call              #Error 4
print Tot (6)                             #Error 4