Sample Questions


How to solve questions in online test

Example 1
Write a program to print length of string
create a function with name "length"

Correct Code
def length(val):
    return len(val)

Wrong Code
def length(val):
    print len(val)

def length(val):
    return len(lav)

Example 2
Write a program to concatenate two strings to greet a user
Function call GreetUser("FOSSEE") should return "Hello FOSSEE"


Correct Code
def GreetUser(val):
    return "Hello" + val

Wrong Code
def GreetUser(val):
    print "Hello" + val

def GreetUser(val):
    print val1 + val