Python Programming exercises and Answers example two: exercises on the axis and long integer data types.

Source: Internet
Author: User
Tags for in range

The problem with Python exercises is as follows:

Summary: The bonus paid by the enterprise is based on the profit commission. Profit (I) less than or equal to $100,000, the bonus can be raised by 10%, the profit is higher than $100,000, less than $200,000, the portion of less than 100,000 yuan by 10% commission, higher than the portion of 100,000 yuan, a commission of 7.5%, 200,000 to 400,000, higher than 200,000 yuan, can commission 5% , between 400,000 and 600,000 is higher than the portion of 400,000 yuan, can commission 3%, 600,000 to 1 million, above the portion of 600,000 yuan, can be a commission of 1.5%, higher than 1 million yuan, the portion of more than 1 million yuan by 1% Commission.

Question: Enter the current month profit I from the keyboard, the total bonus should be issued?

#my stupid way.Profit = Int (input ('profit=')) a= Profit * 0.1b= (profit-100000) * 0.075C= (profit-200000) * 0.05D= (profit-400000) * 0.03e= (profit-600000) * 0.015F= (profit-1000000) * 0.01ifProfit <= 100000:    Print(a)if100000 < profit <= 200000:    Print(A +b)if200000 < profit <= 400000:    Print(A + B +c)if400000 < profit <= 600000:    Print(A + B + C +d)if600000 < profit <= 1000000:    Print(A + B + C + D +e)if1000000 <Profit:Print(A + B + C + D + E + f)
# The answer algorithm, is also understood, to practice mastering a = [1000000, 600000, 400000, 200000, 100000= [0.01, 0.015, 0.03, 0.05 , 0.075, 0.1 = Int (input ('>>>'= 0 for in range (6 ):    if profit > a[i]:        + = (profit-a[i]) * b[i]Print (Bonus)

Python Programming exercises and Answers example two: exercises on the axis and long integer data types.

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.