Ex No: 18 Conditional and Looping Statements
Aim: To write a python program using Conditional and Looping Statements.
Algorithm
Step1: Get input for number of values.
Step2: Get the numbers using while loop and add it to list.
Step3: Display Entered List using for loop.
Step4: Sort the list using nested for loops.
    A) Check for larger number in list and swap the numbers.
Step5: Display the sorted list values.
Source Code
num_list = list()
i=1
num = input("Enter number value: ")
while i<=num:
    val = input("Enter %d number: " %(i) )
    num_list.append(val)
    i += 1

print "Entered List Values are ",
for x in num_list:
    print x,

#Sorting Algorithm
i,j = 0, 0
for i in range(0,num):
    for j in range(i,num):
        if num_list[i]>num_list[j]:
            tmp = num_list[i]
            num_list[i] = num_list[j]
            num_list[j] = tmp

#Display Sorted List
print "\nSorted List Values are ",
for x in num_list:
    print x,    

            
Result: Thus a python program is written using constional and looping statements.