Friday, August 24, 2012

Basic Control Flow in Python

def conditionalStatementTest():
    print("if else statement test:")
    x = int(input("Enter an integer :"))
    if(x < 10) :
        print("x is less then 10")

    elif(x > 10) :
        print("x is grater then 10")

    elif(x == 10) :
        print("x = 10")

def forLoopTest():
    print("Test for loop with range() function")
    for index in range(5):
        print(index)


if  __name__=='__main__':
    conditionalStatementTest()
    forLoopTest()


No comments:

Post a Comment