python判断完全平方数的方法
作者:Guo_Apple 时间:2023-07-12 06:43:13
如下所示:
# -*- coding: utf-8 -*-
#简述:一个整数,它加上100和加上268后都是一个完全平方数
#提问:请问该数是多少?
from math import sqrt
def f(number):
for x in range(0,number):
m=sqrt(x+100)
n=sqrt(x+268)
if m==int(m) and n==int(n):
print x
if __name__=="__main__":
f(1000)
运行结果:
21
261
总结:
a=2.2
b=int(a)
a==b
False
a=2.0
b=int(a)
a==b
True
来源:https://blog.csdn.net/Guo_Apple/article/details/68921795
标签:python,完全平方数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Mysql连接本地报错:1130-host ... is not allowed to connect to this MySQL server解决
2024-01-28 04:52:50
![](https://img.aspxhome.com/file/2023/0/129920_0s.png)
Python利用PyPDF2快速拆分PDF文档
2021-11-06 09:39:23
![](https://img.aspxhome.com/file/2023/1/88881_0s.jpg)
Python如何实现文本转语音
2022-12-23 09:49:22
Oracle数据库的十种重新启动步骤
2012-07-21 14:58:25
tensorflow 加载部分变量的实例讲解
2023-03-27 03:19:56
php中关于socket的系列函数总结
2023-11-17 13:57:35
fgetcvs在linux的问题
2024-06-05 09:37:56
python实现文本进度条 程序进度条 加载进度条 单行刷新功能
2021-04-06 09:29:53
详解Python中的正斜杠与反斜杠
2021-06-28 08:38:10
解决Tensorflow 使用时cpu编译不支持警告的问题
2023-12-30 07:28:01
![](https://img.aspxhome.com/file/2023/0/70780_0s.jpg)
[翻译]标记语言和样式手册 Chapter 2 标题
2008-01-16 11:56:00
![](https://img.aspxhome.com/file/UploadPic/20081/16/2008116121440368s.jpg)
PHPMyadmin2.10中文显示为乱码的解决办法
2007-08-22 08:18:00
python学习数据结构实例代码
2023-09-20 22:56:32
python 中 .py文件 转 .pyd文件的操作
2022-02-17 09:59:38
![](https://img.aspxhome.com/file/2023/8/107458_0s.jpg)
数据库名词解释
2008-09-12 17:28:00
python实现Excel文件转换为TXT文件
2021-01-15 05:24:54
Vue3响应式对象是如何实现的(2)
2024-05-09 15:10:01
![](https://img.aspxhome.com/file/2023/0/126610_0s.png)
python利用多线程+队列技术爬取中介网互联网网站排行榜
2023-05-19 08:17:21
![](https://img.aspxhome.com/file/2023/9/114619_0s.webp)
asp常用的SQL命令操作
2007-09-29 12:21:00
asp如何在ADO中使用存储查询?
2010-06-17 12:52:00