云班课homework 03,04

判断是否为闰年

小知识:公历闰年能被4整除且不能被100整除的为闰年,平均每四年中会有一个闰年,世纪年能被400整除的则是闰年

# -*- coding: utf-8 -*-
"""
功能:判断是否为闰年
作者:cxf
日期:2021年11月4日
"""
# 输入部分
year = int(input('year = '))
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
    print('{}年是闰年'.format(year))
else:
    print('{}年是平年'.format(year))

拆分四位数

# -*- coding: utf-8 -*-
"""
功能:拆分四位数
作者:cxf
日期:2021年11月4日
"""

while id:
    id = int(input('请输入数字:'))
    if id > 999 and id <10000:
        x1, x2, x3,x4 =map(int,str(id))
        print('个位数:{},十位数:{},百位数:{},千位数:{}'.format(x4, x3,x2,x1))
        break
    elseprint('请重新输入一个四位数')
        

猜你喜欢

转载自blog.csdn.net/qq_62590351/article/details/121152936