Fellow Python developers,
Python has a sorted() or sort() function to implement ascending or descending order programs,but supposing if i want to develop a ascending order program that takes user input and ascends or descends them,how should I go about?
For Example: Lets Say i want to convert this C program to Python?
# include <iostream.h>
# include <conio.h>
void main()
{
int a[10],i,j,n,temp;
clrscr();
cout<<"\nEnter n nos: ";
cin>>n;
cout<<"\nEnter the numbers: ";
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
for(i=0;i<n;i++)
cout<<a[i]<<endl;
getch();
}
This is an ascending order program in C.
Thanks in Advance!