Python例题(03)

1.编写程序:

import math as m
(x,y)=eval(input("Enter a point with two coordinates:"))
s = m.sqrt(x**2+y**2)
if s<=10:
	print("Point ",(x,y),'is in the circle')
else:
	print("Point ",(x,y),'is not in the circle')
# Enter a point with two coordinates:4,5
# Point  (4, 5) is in the circle
# Enter a point with two coordinates:9,9
# Point  (9, 9) is not in the circle

2.编写程序:

t = 0
for i in range(100, 1001):
    if i % 5 == 0 and i % 6 == 0:
        print(i, end=' ')
        t = t + 1
        if t % 10 == 0:
            print()
# 120 150 180 210 240 270 300 330 360 390 
# 420 450 480 510 540 570 600 630 660 690 
# 720 750 780 810 840 870 900 930 960 990 

3.编写程序:

t = 0
for i in range(2001,2101):
	if i%4==0 and i % 100 != 0 or i % 400 == 0:
		print(i, end=' ')
		t = t + 1
		if t % 10 == 0:
			print()
# 2004 2008 2012 2016 2020 2024 2028 2032 2036 2040 
# 2044 2048 2052 2056 2060 2064 2068 2072 2076 2080 
# 2084 2088 2092 2096 

4.编写程序:

n = int(input('请输入一个整数:'))
i = 2  # 我们从二开始验证如120%2
while True:
    if n % i == 0:
        print(i, end=" ")
        n /= i
    else:
        i += 1
    if n == 1:
        break
# 请输入一个整数:120
# 2 2 2 3 5 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雨天_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值