Python rewrite C language program 100 cases--part2__python

Source: Internet
Author: User
[Python]   View plain copy print? ' Title: Enter a certain date of the year to determine the day of the year.   1. Procedure analysis: Take March 5 as an example, should first add up the first two months, and then add 5 days that this year, special   situation, leap years and enter a month greater than 3 o'clock to consider an additional day.   2. Program source code:  '    year = int (raw_input (' year:\n '))    Month = int (Raw_input (' month:\n '))    Day = int (raw_input (' day:\n '))       months  =  (0,31,59,90,120,151,181,212,243,273,304,334)    if 0 <= month < = 12:       sum = months[month - 1]   Else:        print  ' data error '    sum += day   leap = 0   if  (year % 400 == 0)  or  (year % 4  == 0)  and  (year % 100 != 0)):       leap  = 1   if  (leap == 1)  and  (month&NBSP;&GT;&NBSP;2):       sum += 1   print  ' It is  the %dth day. '  % sum  
[Python]View Plain copy print?  "" "Program 5" topic: Enter three integer x,y,z, please put these three numbers from small to large output.  1. Procedure analysis: We'll find a way to put the smallest number on X, first compare x to Y, and if x>y the value of x and Y, and then compare X to Z, if X>z swap the value of x and z, it minimizes x. 2. Program source code: "' L = [] for I in range (3): x = Int (raw_input (' integer:\n ')) l.append (x) l.sort () print L

[python] view plain copy print?

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.