zuoye 1-3

# 作业 1

# 1、闰年判断
year = int(input())
if year % 400 == 0 or (year % 4 == 0 and year % 100 !=0):
    print(f'{year}是闰年')
else:
    print(f'{year}不是是闰年')

# 2、韩信点兵
for i in range(1, 1500):
    surplus_num = 1500 - i
    if surplus_num % 3 == 2 and surplus_num % 5 == 4 and surplus_num % 7 == 6 and 1000 <= surplus_num <= 1100:
        print(f'还剩下{surplus_num}人')


# 作业 2

# 1、最大公约数,最小公倍数
def odd(a, b):
    mul = a * b
    res = a % b
    while res != 0:
        a = b
        b = res
        res = a % b
    print(int(b), int(mul / b),sep=', ')
a, b = map(int, input("输入两个数\n").split(','))
odd(a, b)

# 2、输出最大的数和最小的数及最大的数和最小的数的平均值
ls = []
try:
    while True:
        num = eval(input('请输入数字(直接输入回车退出):'))
        ls.append(num)
except:
    pass
for i in ls:
    print(i, end=' ')
print()
print("最大的数:" + str(max(ls)), "最小的数:" + str(min(ls)), "最大的数和最小的数的平均值:" + str((max(ls) + min(ls))/2))



# 作业 3

# 1、小球
high = 100
fall_high = 100
all_high = 0
for i in range(10):
    fall_high /= 2
    if i != 9:
        all_high += fall_high * 2
print(f'第十次落地总共经历{all_high + high}m')
print(f'第十次反弹高度为{fall_high}m')


# 2、在当前目录下创建一个文本文件test.txt,并向其中写入字符串hello world
with open('test.txt', 'w') as file:
    file.write('hello world')

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值