Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the practical cases of Python rookies?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the practical cases of Python rookies". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Case 1: permutation and combination

Request:

List all the different and non-repetitive permutations and combinations that may be made up of four numbers.

Analysis:

What is there to analyze? Just arrange it.

Code:

Case 2: ladder summation

Request:

Enterprises implement step-by-step sales performance plan. It is now stipulated that:

10% commission when sales are less than or equal to 100000

When sales are less than or equal to 200000, 7.5% of the portion over 100000 will be deducted, the rest from above

When the sales are less than or equal to 400000, the commission will be 5% for the portion over 200000, and the rest from above.

When the sales are less than or equal to 600000, the commission of more than 400000 is 3%, and the rest is above.

When sales are less than or equal to 1 million, 1.5% of the portion exceeding 600000 will be deducted from above.

When sales are higher than 1 million yuan, 1% of the portion exceeding 1 million will be given a commission, with the rest from above.

Ask to enter someone's sales to get the due performance.

Analysis:

1. Use the number axis to demarcate and locate.

two。 There is no truth that the higher the sales, the lower the commission.

Code:

Case 3: find the integer value

Request:

If the integer iquotient 100 is a complete square number, plus 168 is a complete square number, the value of the integer is obtained.

Analysis:

Judging within 100000, first add the number 100 before the prescription, and then add the number to 268 before the prescription, if the result meets the following conditions, it is the result.

Code:

Case 4: number of days to judge

Request:

Enter the year, month and day in order to determine the day of the year.

Analysis:

Enter any date such as May 3, now add the number of days from January to April, and add the current date 5. Pay attention to the form of leap years.

Code:

Case 5: integer sorting

Request:

Enter three integers xyz and output them in size order.

Analysis:

If you are slower, you will compare the sizes one by one, but the Python list can use the sort function, so it is much more convenient.

Code:

Case 6: output character painting

Request:

Use the "*" to output the simple letter P.

Analysis:

... Speechless.

Code:

Case 7: chr usage

Request:

There are no more demands. It feels like the author is showing off his skills.

Analysis:

Well, go and see for yourself.

Code:

Case 8: multiplication table

Request:

Output the 99 multiplication table.

Analysis:

A case that must be done to get started. No more analysis.

Code:

Case 9: output chessboard

Request:

Output chess board (black and white)

Analysis:

Use I to control the row, j to control the column, and output black square or white square according to the change of the sum of iSum j.

Code:

Case 10: print stairs

Request:

Print a stair drawing.

Analysis:

Use I to control rows, j to control columns, and j to control the number of output black squares according to changes in I.

Code:

This is the end of the introduction of "what are the practical cases of Python rookies". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report