Python Learning notes section 11th (Iterations and others)

Source: Internet
Author: User

Process programming for yiled faces

Build the content and distribute it to the following

This is a stupid version.

Built-in functions

Print (Divmod (10,3)) divides 10 by 3, showing quotient and remainder

The enumerate function, which displays the element and its index, is the iterator behind the enumerate

Range backwards.

Step of the Slice

Rounding retains 3 decimal places

Calculation
Apple 10 3
Tesla 100000 1
MAC 3000 2
Lenovo 30000 3
Chicken 10 3
The total price of the quantity and price of these goods List

The above is a relatively low wording

Above this is the generator expression
There's this kind of operation, notice.

Over here

Another optimized version, this is the generator expression

Error version because the indent file for print has been closed, so print (sum (g)) needs to be indented to the g= position


Use this text to extract data as a database

Here's the lite version.

Salary comparison size

Usage of Map Map

Usage of reduce

Filter filters out the result of a bool value of TRUE

The sorted function arranges the list in order and does not change the list

Flip arrangement

Recursive invocation
Infinite recursive loop caps can be changed

Recursive backtracking

Recursive reckoning age

Recursive application, when you do not know how many times the loop, only know the time to meet the conditions with recursion.
Recursive, calling itself the function itself
Cons: Each recursive saves the function state, wasting memory

Python Learning notes section 11th (Iterations and others)

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.