Python Simple loop-small programming

Source: Internet
Author: User
1.99 Variants of the multiplication table:

Idea: Use the For loop and range function to calculate the Chuyang product over and over again, and use the Format function to align right to achieve the effect on the graph.

2. Print the Diamond:

Idea: Using the mathematical function equation, establish a coordinate system with the center point as the origin point, such as:

To facilitate the understanding of the x-axis left-to-right by negative to positive, the y-axis down from negative to positive, to find out the expression of four functions, the use of the if sentence to determine the intersection of printing, the rest is "".

3. Print to the top triangle:

Ideas: With the same, take Y=x and Y=-x intersection, to print

4. Print Lightning:

The above-mentioned diamond is modified, using the IF statement to take its two or four quadrant printing

5. Ask for the Fibonacci sequence:

Idea: A method of marking is used, which is equivalent to a switch

6. Seeking prime numbers:

Idea: According to the prime number can only be 1 and its own division, in order to make its operation speed, will be even singled out, and secondly, because of the divide relationship, just to calculate to open the square around it can be.

Python Simple loop-small programming

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.