《Python实验2选择结构程序设计》由会员分享,可在线阅读,更多相关《Python实验2选择结构程序设计(3页珍藏版)》请在人人文库网上搜索。
1、实验2 选择结构程序设计1、 预测你的小孩的身高 男性身高=(父亲身高+母亲身高)1.082(厘米)女性身高=(父亲身高0.923+母亲身高)2(厘米) #predicting your childs heightprint The following calculating unit is cm.x=input(Please enter dads height:,)y=input(Please enter moms height:,)g=raw_input(Please enter your childs gender:)if g=male:h=(x+y)*1.08/2print h,cmi。
2、f g=female:h=(x*0.923+y)/2print h,cm2、 输入一个年份,判断它是否为闰年,并输出是否为闰年的相关信息。【提示】判断闰年的条件是:年份能被4整除但不能被100整除;或者是能被400整除。如:1900、2100、2010年不是闰年;2008、2000年是闰年。y=input(Please enter the year:)if y%4=0 and y%100!=0 or y%400=0:print y,是闰年else:print y,不是闰年3、 输入一个学生的成绩,如果是90分以上,打印出“A”的评语;80分以上的,打印出“B”;70分以上的,打印出“C”;60。
3、分以上的,打印出“D”;不及格的打印出”E”。print This is a procedure which can print the