实验步骤:1.编写一个类,创建两个数组用于存放从1901到2050年之间所有的闰月,闰年,之后再通过编写几个函数,将阳历转化为阴历,输出即可。2.根据图形找‘*’,‘’分别与行数i之间的关系及规律,然后用for循环控制输出即可。3.根据阶乘计算方法用for循环依次计算乘积,直到满足条件为止,然后用if语句控制输出即可。4.运行程序,根据报错信息发现程序的问题。5.编写一个函数,用for循环遍历所有三位数,当数符合水仙花条件:一个三位数,其各位数字立方和等于该数本身,将此数输出即可。6.编写一个函数,把用户密码设置为一个字符串,将用户输入的密码与设置的密码进行比较,如果相同,输出“密码输入正确!”;如果用户密码里包含‘*’,则不算输入错误,但需要重新输入;其他输入情况都算输入错误,计入输入错误的次数,当用户输入错误次数超过3次时,用户不能再输入密码。实验结果:1.公历2017-12-19农历冬月初二2.pleaseinputthenumberofraw:4****************3.1的阶乘是:12的阶乘是:23的阶乘是:64的阶乘是:245的阶乘是:1206的阶乘是:7207的阶乘是:50408的阶乘是:403209的阶乘是:36288010的阶乘是:362880011的阶乘是:3991680012的阶乘是:47900160013的阶乘是:622702080014的阶乘是:8717829120015的阶乘是:130767436800016的阶乘是:2092278988800017的阶乘是:35568742809600018的阶乘是:640237370572800019的阶乘是:12164510040883200020的阶乘是:24329020081766400004.python中函数可以嵌套定义,但在函数内部定义的函数只能在内部使用,外部无法调用5.water()水仙花数是:1533703714076.testify()pleaseinputyourpassword:123456输入正确!testify()pleaseinputyourpassword:1pleaseinputyourpassword:2pleaseinputyourpassword:3*pleaseinputyourpassword:4testify()pleaseinputyourpassword:1pleaseinputyourpassword:2pleaseinputyourpassword:3*pleaseinputyourpassword:4*pleaseinputyourpassword:123456输入正确!testify()pleaseinputyourpassword:1pleaseinputyourpassword:1pleaseinputyourpassword:1疑难小结:1.输出三角图形时一直报参数类型错,经检查,发现raw_input()是输入字符串,与for循环里的行数n类型不一致,改成input()后解决了此问题。2.python中函数可以嵌套定义,但在函数内部定义的函数只能在内部使用,外部无法调用3.阳历转阴历,研究了好久,也没什么头绪。经上网查询资料,大概了解了下阴历,阳历之间的关系,发现还挺复杂的,因为主要需要考虑闰年和闰月的问题。程序清单:1.importdatetimeclassLunar(object):g_lunar_month_day=[0x4ae0,0xa570,0x5268,0xd260,0xd950,0x6aa8,0x56a0,0x9ad0,0x4ae8,0x4ae0,#19100xa4d8,0xa4d0,0xd250,0xd548,0xb550,0x56a0,0x96d0,0x95b0,0x49b8,0x49b0,#19200xa4b0,0xb258,0x6a50,0x6d40,0xada8,0x2b60,0x9570,0x4978,0x4970,0x64b0,#19300xd4a0,0xea50,0x6d48,0x5ad0,0x2b60,0x9370,0x92e0,0xc968,0xc950,0xd4a0,#19400xda50,0xb550,0x56a0,0xaad8,0x25d0,0x92d0,0xc958,0xa950,0xb4a8,0x6ca0,#19500xb550,0x55a8,0x4da0,0xa5b0,0x52b8,0x52b0,0xa950,0xe950,0x6aa0,0xad50,#19600xab50,0x4b60,0xa570,0xa570,0x5260,0xe930,0xd950,0x5aa8,0x56a0,0x96d0,#19700x4ae8,0x4ad0,0xa4d0,0xd268,0xd250,0xd528,0xb540,0xb6a0,0x96d0,0x95b0,#19800x49b0,0xa4b8,0xa4b0,0xb258,0x6a50,0x6d40,0xada0,0xab60,0x9370,0x4978,#19900x4970,0x64b0,0x6a50,0xea50,0x6b28,0x5ac0,0xab60,0x9368,0x92e0,0xc960,#20000xd4a8,0xd4a0,0xda50,0x5aa8,0x56a0,0xaad8,0x25d0,0x92d0,0xc958,0xa950,#20100xb4a0,0xb550,0xb550,0x55a8,0x4ba0,0xa5b0,0x52b8,0x52b0,0xa930,0x74a8,#20200x6aa0,0xad50,0x4da8,0x4b60,0x9570,0xa4e0,0xd260,0xe930,0xd530,0x5aa0,#20300x6b50,0x96d0,0x4ae8,0x4ad0,0xa4d0,0xd258,0xd250,0xd520,0xdaa0,0xb5a0,#20400x56d0,0x4ad8,0x49b0,0xa4b8,0xa4b0,0xaa50,0xb528,0x6d20,0xada0,0x55b0,#2050]#数组gLanarMonth存放阴历1901年到2050年闰月的月份,如没有则为0,每字节存两年g_lunar_month=[0x00,0x50,0x04,0x00,0x20,#19100x60,0x05,0x00,0x20,0x70,#19200x05,0x00,0x40,0x02,0x06,#19300x00,0x50,0x03,0x07,0x00,#19400x60,0x04,0x00,0x20,0x70,#19500x05,0x00,0x30,0x80,0x06,#19600x00,0x40,0x03,0x07,0x00,#19700x50,0x04,0x08,0x00,0x60,#19800x04,0x0a,0x00,0x60,0x05,#19900x00,0x30,0x80,0x05,0x00,#20000x40,0x02,0x07,0x00,0x50,#20100x04,0x09,0x00,0x60,0x04,#20200x00,0x20,0x60,0x05,0x00,#20300x30,0xb0,0x06,0x00,0x50,#20400x02,0x07,0x00,0x50,0x03#2050]START_YEAR=1901#月份lm='正二三四五六七八九十冬腊'#日份ld='初一初二初三初四初五初六初七初八初九初十十一十二十三十四十五十六十七十八十九二十廿一廿二廿三廿四廿五廿六廿七廿八廿九三十'def__init__(self,dt=None):'''初始化:参数为datetime.datetime类实例,默认当前时间'''self.localtime=dtifdtelsedatetime.datetime.today()defln_year(self):#返回农历年year,_,_=self.ln_date()returnyeardefln_month(self):#返回农历月_,month,_=self.ln_date()returnmonthdefln_day(self):#返回农历日_,_,day=self.ln_date()returndaydefln_date(self):#返回农历日期整数元组(年、月、日)(查表法)delta_days=self._date_diff()#阳历1901年2月19日为阴历1901年正月初一#阳历1901年1月1日到2月19日共有49天if(delta_days49):year=self.START_YEAR-1if(delta_days19):month=11;day=11+delta_dayselse:month=12;day=delta_days-18return(year,month,day)#下面从阴历1901年正月初一算起delta_days-=49year,month,day=self.START_YEAR,1,1#计算年tmp=self._lunar_year_days(year)whiledelta_days=tmp:delta_days-=tmpyear+=1tmp=self._lunar_year_days(year)#计算月(foo,tmp)=self._lunar_month_days(year,month)whiledelta_days=tmp:delta_days-=tmpif(month==self._get_leap_month(year)):(tmp,foo)=self._lunar_month_days(year,month)if(delta_daystmp):return(0,0,0)return(year,month,delta_days+1)delta_days-=tmpmonth+=1(foo,tmp)=self._lunar_month_days(year,month)#计算日day+=delta_daysreturn(year,month,day)defln_date_str(self):#返回农历日期字符串,形如:农历正月初九_,month,day=self.ln_date()return'农历{}月{}'.format(self.lm[month-1],self.ld[(day-1)*2:day*2])#显示日历defcalendar(self):pass########################################################下面皆为私有函数#######################################################def_date_diff(self):'''返回基于1901/01/01日差数'''return(self.localtime-datetime.datetime(1901,1,1)).daysdef_get_leap_month(self,lunar_year):flag=self.g_lunar_month[(lunar_year-self.START_YEAR)//2]if(lunar_year-self.START_YEAR)%2:returnflag&0x0felse:returnflag4def_lunar_month_days(self,lunar_year,lunar_month):if(lunar_yearself.START_YEAR):return30high,low=0,29iBit=16-lunar_month;if(lunar_monthself._get_leap_month(lunar_year)andself._get_leap_month(l