Introducing ten small examples of Python, where newbies get started


Follow the public right now, Discovering the beauty of the world

Today we share with you tenPython A small case of entry level。

Case 1: ranking combination

request:

will4 List all possible permutations of numbers that are not identical and have no repetition。

analysis:

Just line it up.

code:

Case 2: summation of steps

request:

Businesses implement ladder sales performance programs。 current rule:

10% commission on sales less than or equal to 100,000;

Sales less than or equal to20 ten thousand hours, surpass10 Part of the commission of 10,0007.5%, Others from above;

Sales less than or equal to40 ten thousand hours, surpass20 Part of the commission of 10,0005%, Others from above;

Sales less than or equal to60 ten thousand hours, surpass40 Part of the commission of 10,0003%, Others from above;

Sales less than or equal to100 ten thousand hours, surpass60 Part of the commission of 10,0001.5%, Others from above;

Sales above100 $1,000,000 when, surpass100 Part of the commission of 10,0001%, Others from above。

Request to enter a person's sales, Deriving performance entitlements。

analysis:

1. Use the number axis to demarcate, locate。

2. There's no reason why the higher the sales, the lower the commission...

code:

Case 3: integer value

request:

with integersi,i+100 is a perfect square number, plus168 Another perfect square number, Find the value of the integer。

analysis:

(located) at10 Judgment within 10,000, First add that number to100 postscript, Then add that number to268 postscript, If the result of the opening square satisfies the following conditions, is the result。

code:

Case 4: Number of days to judge

request:

Sequential input year、 month、 sun, Determine what day of the year the input date is。

analysis:

Enter any date such as5 month3 sun, herewith1-4 Number of days per month added together, Plus the current date5 can then (do sth)。 Note the form of leap years。

code:

Case V: Integer sorting

request:

Enter three integersxyz, and output them in order of size。

analysis:

Slowly., Just comparing sizes one by one, merelyPython The list can be accessed with thesort function, So it's much easier.。

code:

Case 6: Output character drawing

request:

use“*” Output simple lettersP。

code:

Case 7:chr use

request:

No request.

code:

Case 8: multiplication mnemonic table

request:

exports99 multiplication table。

analysis:

A must-do case to get started

code:

Case 9: Output board

request:

Exporting the chess board( black and white pattern)

analysis:

usefulnessi control line,j to control the column, depending oni+j to control the output black square by the change in the sum of, It's still a white square.。

code:

Case 10: Printed stairs

request:

Print a stairway graphic。

analysis:

usefulnessi control line,j to control the column,j depending oni to control the number of black squares in the output。

code:

Ten cases are small but each of them is full of code wisdom, Feel free to repost+ Comment!!


Recommended>>
1、Our North Campus Pinnacle³ successfully completed maintenance work
2、Wallets of overseas project analysis gurus stolen several coins tragically smashed
3、There are several common ways to unlock your smartphone which one is your favorite
4、The price for pissing us off is 80000 hackers taking down the White House FBI NASA and other websites
5、Welcome 2018 with design GOOOOOOOOOOOOOOOOO

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号