[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;>&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?