Getting Started with Python 4 (bubbling Sort)

Source: Internet
Author: User

After learning the most basic Python syntax, let's practice one of the simplest bubble sorts and check if you're getting started. If a CSL classmate can not understand the words, go back to the basic grammar of reading books

1 defbubble_sort (lists):2     #Bubble Sort3Count =len (lists)4      forIinchRange (0, count):5          forJinchRange (i + 1, count):6             ifLists[i] >Lists[j]:7Lists[i], lists[j] =Lists[j], Lists[i]8     returnlists9a=[1,5,9,8,7,4,1.2,1.6,2.3]TenBubble_sort (a)

Where code First line DEF is a function-defined format

Getting Started with Python 4 (bubbling Sort)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.