Flowchart to sort the list of numbers in python-my programming school

Flowchart to sort list of numbers python

In this program, we will learn to draw a flowchart for sorting array elements.

Algorithm:

  • Step1: Start
  • Step 2: Enter the array size and read as n.
  • Step 3: Enter the array elements and read as [i].
  • Step 4: Print the array elements before sorting.
  • Step5: After sorting, print the statement array elements.
  • Step6: Take 2 nested loops, take i variable in 1 loop, and j variable in 1 loop.
  • Step7: Check condition i> n in the I loop.
  • Step8: If the condition is false, go to the j loop. Go to the other end.
  • Step9: In j loop, check condition [j]> [a + j + 1].
  • Step10: If the condition is true, swap one [j] and one [j + 1]. Otherwise, go to the end.
  • Step11: Print the array elements [i].
  • Step 12: End

Flow Chart Diagram

Flowchart to sort the list of numbers in python
Flowchart to sort the list of numbers
Flowchart to sort list of numbers
Flowchart to sort the list of numbers

Source Code:

Sort the list of number in Ascending Order

# Sort the list of integer number
number = [11,23,32,43,21,45,63,76,4]
# sort the list in assending order
number.sort()
print('list assending:',number)

Sort the list of number in Descending Order

number = [11,23,32,43,21,45,63,76,4]
# sort the list of number in decending order
number.sort(reverse = True)
print('List decending:',number)

Sort the list in single line of code

number = [11,23,32,43,21,45,63,76,4]
# sort the list of number in single line
print('Sorted list:',sorted(number))

Sort the list using key

def sorting(numbers):
    return numbers[1]
list_tupl = [(1,3), (4,2), (7,1), (9,7)]

# sort the list of tuple in assending order
list_tupl.sort(key = sorting)

# sort the list of tuple in decending order
list_tupl.sort(reverse = True)
print('Set of tuple decending',list_tupl)

Related Posts:

Get Salesforce Answers

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.



Leave a Comment