python作业网站_怒刷python作业-WEB资讯专栏-DMOZ中文网站分类目录-免费收录各类优秀网站的中文网站目录....

news/2024/5/17 1:59:53/文章来源:https://blog.csdn.net/weixin_42318030/article/details/113969710

以下作业题仅为参考答案 为了锻炼思维的目的 所有的底层操作都是独立实现 尽量少的引包 大家对题有更好的思路和更方便的包欢迎大家多多留言 祝愿大家共同进步1 hello word 略… 2A B A int(input())B int

以下作业题仅为参考答案,为了锻炼思维的目的,所有的底层操作都是独立实现,尽量少的引包,大家对题有更好的思路和更方便的包欢迎大家多多留言,祝愿大家共同进步

2f52bf982ba314678cc0bcec17480948.png

1 hello word

略…

2A+B

c59db3557bb6356a0e7aa87b75faf973.png

A = int(input())

B = int(input())

print(A+B)

3N位小数

01759ff82a42e84be237bb814a394ec1.png

f = float(input())

n = int(input())

print(round(f,n))

4二进制(题目错误,只要第二个输出的也是a的二进制题目就能通过)

7cadad35ccea61ab5a9c2248c6319251.png

调用函数

a = int(input())

b = int(input())

print(bin(a),bin(b),a & b)

全部自己实现

a = int(input())

b = int(input())

def toBin(num):

s = ""

while num > 0:

s += str(num&1)

num >>= 1

l = list(s)

l.reverse()

return "".join(l)

print("0b"+toBin(a))

print("0b"+toBin(b))

5ASCII

e47dcdfa1444f9161c8349119f68bcc9.png

n = int(input())

a = input()

print(chr(n),ord(a))

6进制转换

21b296d0e5fd12fef204455d7417c441.png

n = int(input())

print(oct(n), hex(n),bin(n), sep = ",")

7整数格式输出

9e1580af682bbfdad3fe81deb90a59d4.png

a = int(input())

print("{:<10d}".format(a))

print("{:>10d}".format(a))

print("{:

print("{:>+10d}".format(abs(a)))

8浮点数输出

50472e26de9fe049ef2dabe52f0512cb.png

a = float(input())

print("{:<.6f sep="/">

9各种表示

1543d00685fc9504d2ea137c14af4ea6.png

a = int(input())

print('{:b}'.format(a), '{:o}'.format(a), oct(a), '{:x}'.format(a), hex(a), '{:#X}'.format(a), sep = ",")

10动态宽度

d196ffcd3f748a4dc7baff9729445747.png

m = int(input())

n = int(input())

def toBin(num):

s = ""

for i in range(0, n):

s += str(num&1)

num >>= 1

l = list(s)

l.reverse()

return "".join(l)

print(toBin(m))

11两个分数加减乘除

1b2505043fbc8d5238f09e65805dfe5e.png

a = int(input())

b = int(input())

c = int(input())

d = int(input())

def simple(d):

a = d['molecule']

b = d['denominator']

while a%b != 0:

tmp=a%b

a = b

b = tmp

d['molecule'] /= b

d['denominator'] /= b

dict = {'molecule':a*d+b*c, 'denominator':b*d}

simple(dict)

print("("+str(a)+"/"+str(b)+")"+"+("+str(c)+"/"+str(d)+")"+"="+str(int(dict['molecule']))+"/" + str(int(dict['denominator'])))

dict['molecule'] = a*d-b*c

simple(dict)

print("("+str(a)+"/"+str(b)+")"+"-("+str(c)+"/"+str(d)+")"+"="+str(int(dict['molecule']))+"/" + str(int(dict['denominator'])))

dict['molecule'] = a*c

simple(dict)

print("("+str(a)+"/"+str(b)+")"+"*("+str(c)+"/"+str(d)+")"+"="+str(int(dict['molecule']))+"/" + str(int(dict['denominator'])))

dict['molecule'] = a*d

dict['denominator'] = b*c

simple(dict)

print("("+str(a)+"/"+str(b)+")"+"/("+str(c)+"/"+str(d)+")"+"="+str(int(dict['molecule']))+"/" + str(int(dict['denominator'])))

12计算狗的年龄

5a81fa5ead188a36f1450bb2b6eb8535.png

a = int(input())

if a<=2:

print(a*10.5)

else:

print(int(2*10.5+(a-2)*4))

13风寒指数

b75f1fad2bf81986b3bde8f2ff513f4f.png

import math

v = float(input())

t = float(input())

chill = 13.12+0.6215*t-11.37*math.pow(v, 0.16)+0.3965*t*math.pow(v, 0.16)

print(round(chill))

14圆柱

8be45c5589e6c92e2719ed2950995ced.png

import math

h = float(input())

r = float(input())

pai = 3.14159265

print("{:.4f}".format(pai*pow(r, 2)*h))

print("{:.4f}".format(pai*pow(r, 2)*2+2*pai*r*h))

15直角坐标转换为极坐标

6554695d326095034f449f430b941566.png

import math

x = float(input())

y = float(input())

print("{:.4f}".format(math.sqrt(pow(x, 2)+pow(y, 2))), "{:.4f}".format(math.atan2(y, x)), sep = ",")

16给定经纬度计算地球上两点之间的距离

e357be13d4b74e2a4a70ac9f1f0726d7.png

import math

latitude1 = math.radians(float(input()))

longitude1 = math.radians(float(input()))

latitude2 = math.radians(float(input())) #纬度

longitude2 = math.radians(float(input())) #经度

#经纬度转换弧度

def har(th):

return math.pow(math.sin(th/2), 2)

#求差值

vlon = abs(longitude1 - longitude2)

vlat = abs(latitude1 - latitude2)

h = har(vlat)+math.cos(latitude1)*math.cos(latitude2)*har(vlon)

print("{:.4f}".format(2*6371*math.asin(math.sqrt(h))), "km", sep = "")

17勾股定理

ff9388013cf1836f27f6c0de3194a38a.png

import math

a = int(input())

b = int(input())

max = a if a>b else b

min = a if a

def isTriangle(a, b, c):

if a+b > c and a+c > b and b+c > a and abs(a-b) < c and abs(a-c) < b and abs(c-b) < a:

return True

else:

return False

condition1 = int(math.sqrt(math.pow(max, 2) - math.pow(min,2)))

condition2 = int(math.sqrt(math.pow(max, 2) + math.pow(min,2)))

if(isTriangle(min, max, condition2) and math.pow(min, 2)+math.pow(max, 2) == math.pow(condition2, 2) and condition2 > max):

print("c")

elif(isTriangle(min, max, condition1) and math.pow(min, 2)+math.pow(condition1, 2) == math.pow(max, 2) ):

if condition1

print("a")

if condition1min:

print("b")

else:

print("non")

18RGB转换HSV

fbf2c024f2182e8c15330d9d704d280d.png

R = int(input())/255

G = int(input())/255

B = int(input())/255

def max(a, b, c):

m = a if a > b else b

m = m if m > c else c

return m

def min(a, b, c):

m = a if a < b else b

m = m if m < c else c

return m

V = maximum = max(R, G, B)

minimum = min(R, G, B)

S = (maximum - minimum)/maximum

if maximum == R:

H = (G-B)/(V-minimum)

if maximum == G:

H = 2+(B-R)/(maximum-minimum)

if maximum == B:

H = 4+(R-G)/(maximum-minimum)

H *= 60

if H<0:

H += 360

print("{:.4f}".format(H), "{:.4%}".format(S), "{:.4%}".format(V), sep = ",")

19比率

3c52089bae05436b55383f267ed5943e.png

f = float(input())

# 分数通分

def simple(d):

a = d['molecule']

b = d['denominator']

while a%b != 0:

tmp=a%b

a = b

b = tmp

d['molecule'] /= b

d['denominator'] /= b

# 判断小数位有几位

len = len(str(f))-len(str(int(f)))-1

dict = {'molecule':f*pow(10, len), 'denominator':pow(10, len)}

simple(dict)

print(str(int(dict['molecule']))+"/" + str(int(dict['denominator'])))

20.指定精度输入

7dc202e2862bdd20870b502f8a65a06e.png

f = float(input())

n = int(input())

s = str(f)[0:len(str(int(f)))+n+2]

if(int(s[len(s)-1])>4):

s2 = str(int(s[len(s)-2])+1)

else:

s2 = str(int(s[len(s)-2]))

s = s[0:len(str(int(f)))+n]+s2

print(s)

21.整数组合

90f669ed5fe13dd3bb2acb37479283e1.png

import math

n = int(input())

m = int(input())

sum = 0

for i in range(m):

sum += n*int(math.pow(10, i))*(m-i)

print(sum)

# 解法为按位计算,第一次循环统计各位,第二次十位以此类推...每一位的个数随循环减少

# 555

# 55

# 5

# pow(10, i)效率还可以提升,利用迭代

sum = 0

tmp = 1

for i in range(m):

sum += n*tmp*(m-i)

tmp *= 10

print(sum)

22.组合数

0f0136672ab7a3a4fba8b93ad13d0701.png

n = int(input())

count = 0

for a in range(10):

for b in range(10):

for c in range(10):

d = n-a-b-c

if 0 <= d <= 9:

count += 1

print(count)

23对称数

e80b5602d72f75f405118e8775f24750.png

integer = int(input())

def isSymmetry(a, b):

if (a=='9'and b=='6') or (a=='6'and b=='9') or a == b:

return True

else:

return False

flag = True

for i in range(len(str(integer))>>1):

if False == isSymmetry(str(integer)[i], str(integer)[len(str(integer))-i-1]):

flag = False

if flag:

print("Yes")

else:

print("No")

24.平行线

0f825640386fc2d3eec11cd588f2f3a2.png

x1 = float(input())

y1 = float(input())

x2 = float(input())

y2 = float(input())

x3 = float(input())

y3 = float(input())

x4 = float(input())

y4 = float(input())

if(y2-y1)/(x2-x1) == (y4-y3)/(x4-x3):

print("Yes")

else:

print("No")

25.阶乘末尾

472d7e9d6d59175dfd33ba8fac675536.png

n = int(input())

product = 1

for i in range(1, n+1):

product *= i

num = 0

for i in range(len(str(product))):

if('0' == str(product)[len(str(product))-i-1]):

num+=1

else:

break

print(num)

26.操作数

ee9a194059487dd99fc1a250125d1e68.png

n = int(input())

def count(n):

sum = 0

while(n > 0):

sum += int(n%10)

n /= 10

return sum

nums = 0

while n>0:

n -= count(n)

nums += 1

print(nums)

27.斐波那契数列

432a282d42485aaeae915a07bb7c38a4.png

n = int(input())

def fib(n):

if 1 == n or 2 == n:

return 1

a = 0

b = 1

c = 1

for i in range(n-2):

a = b

b = c

c = a+b

return c

print(fib(n))

28.圆

f0d2c287a673e3eb108854c7f20d13cd.png

import math

x1 = int(input())

y1 = int(input())

x2 = int(input())

y2 = int(input())

x3 = int(input())

y3 = int(input())

a=2*(x2-x1)

b=2*(y2-y1)

c=2*(x3-x2)

d=2*(y3-y2)

e=x2*x2+y2*y2-x1*x1-y1*y1

f=x3*x3+y3*y3-x2*x2-y2*y2

x=(b*f-d*e)/(b*c-d*a)

y=(c*e-a*f)/(b*c-d*a)

r=math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1))

print("{:.3f}".format(r), "{:.3f}".format(x), "{:.3f}".format(y), sep = ",")

29.回文数

67d34aa5975fac5203cbd11c65c6ec06.png

integer = int(input())

def isSymmetry(a, b):

if a == b:

return True

else:

return False

flag = True

for i in range(len(str(integer))>>1):

if False == isSymmetry(int(str(integer)[i]), int(str(integer)[len(str(integer))-i-1])):

flag = False

if flag:

print("Yes")

else:

print("Not")

代码改进

n = int(input())

s = str(n)

res = ""

for i in range(len(str(n))):

res += str(s[i])

if int(res) == n:

print("Yes")

else:

print("Not")

30.方程组

0a17acaa84e0955f50b28daa2b54b690.png

a = float(input())

b = float(input())

c = float(input())

d = float(input())

e = float(input())

f = float(input())

if a/d == b/e and a/d != c/f:

print("error")

else:

x=(c*e-f*b)/(a*e-d*b)

y=(c*d-a*f)/(b*d-e*a)

print("{:.3f}".format(x), "{:.3f}".format(y), sep = " ")

以上信息来源于网络,如有侵权,请联系站长删除。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_760532.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux服务器运行程序shell脚本,linux怎么执行shell脚本_网站服务器运行维护

linux如何查看防火墙是否开启_网站服务器运行维护linux查看防火墙是否开启的方法是&#xff1a;1、首先&#xff0c;执行【cd /etc/init.d/】命令&#xff0c;进入init.d目录&#xff1b;2、然后&#xff0c;执行【/etc/init.d/iptables status】命令查看防火墙状态即可。Linux…

奇奇seo优化软件_上饶seo快速优化软件手段

手段seope4c65快速优化软件上饶&#xff0c;随着网络推广方式的快速更新&#xff0c;企业网络推广部门每次都会尝试一种新的推广方式&#xff0c;效果很好。事实上&#xff0c;新的网络推广方式可能并不适合企业。因为不同的企业适合不同的网络推广方式&#xff0c;你尝试太多是…

autojs打包apk源码提取_最新女神直播间付费观看网站源码+视频教程

最新女神直播间付费观看网站源码视频教程、最新女神大秀直播间打赏视频an雷付费观看网站源码 自带直播数据这个大秀直播间的界面什么的都非常诱人&#xff0c;这个东西不便多说&#xff0c;已经全部打包。老司机明白就行。源码已测试无任何bug&#xff0c;完美搭建。里面附带了…

连筋字体在线生成_不会字体设计?有这6个在线字体生成网站就够了

各种设计好的字体样式&#xff0c;非常适用各种活动海报设计与商品促销场景&#xff0c;艺术字体生成器是一个自动生成字体的网站&#xff0c;直接选字体&#xff0c;以及字体大小&#xff0c;还有背景https://www.qt86.com/​可以在先预览效果&#xff0c;更改颜色&#xff0c…

https协议 ppt 下载卷_六个免费PPT模板下载网站(建议收藏!)

关于学习PPT的制作技巧&#xff0c;很大一部分原因莫过于为了效率&#xff0c;那么制作PPT效率最快的方式就是套模板了。我目前了解大概十个左右免费下载的PPT模板网站&#xff0c;但是质量参差不齐&#xff0c;通过自己亲测下载过程&#xff0c;筛选出六个&#xff0c;分享给大…

腾讯旗下网站的很多URL都包含“cgi-bin”,是什么意思?他们后台用什么语言?...

cgi-bin 这很有可能说明后台是C/C写的. 动态Web技术刚出来的时候, 服务器调用本地应用程序处理http请求的技术. 通常是C/C程序. 后来有了新的web开发技术后这类用的就比较少了. url后缀有个经验. php asp结尾的顾名思义可以知道是什么语言写的 .do .action .jsp 通常是java技术…

如何使用阿里云搭建个人网站

国内比较早的几个个人网站有阮一峰、月光博客等。他们都会定期的更新一些文章&#xff0c;阮一峰的更新频率大概在每月4篇&#xff0c;月光博客每天一篇。他们每天的浏览量在2万以上&#xff0c;每月最低收入都在2万以上。作为一个程序员&#xff0c;我一直想给自己找点事情做。…

蓝色给自己的网站加一个好看的跳转页面代码

新建一个文本文档&#xff0c;然后重命名为index.html 复制代码粘贴进去&#xff0c;找到本站地址www.12580sky.com替换成你要跳转的地址就可以了。 <html> <head><meta http-equiv"Content-Type" content"text/html; charsetUTF-8">&…

十年建站老司机带你十分钟搭建网站

本文概要&#xff1a; 1. 域名 域名注册 域名备案 域名解析绑定 2. 服务器 虚拟主机 windows服务器 linux服务器 3. CMS建站系统 4. 总结 在如今互联网发展迅速猛进的大环境下&#xff0c;网站已经成为一个企业不可缺少的网络媒介。但网站开发行业鱼龙混杂&a…

非常牛逼的橙色的app租房网站商城手机站模板html整站

非常牛逼的橙色的app租房网站商城手机站模板html整站 gif动图 源码下载地址http://www.zuidaima.com/share/3608793364532224.htm

【使用DIV+CSS重写网站首页案例】CSS选择器

使用表格<table></table>对网站首页进行布局有缺陷&#xff0c;不能拖动版块&#xff0c;不灵活。 DIV Div是一个html的标签&#xff0c;单独使用没有意义&#xff0c;必须结合CSS使用&#xff1b; 是一个块级元素&#xff0c;单独占一行&#xff1b; 它主要用于页…

【使用DIV+CSS重写网站首页案例】CSS引入方式

CSS引入方式&#xff08;3种&#xff09; *就近原则&#xff1a;行内引入可以覆盖内部引入的效果 内部引入&#xff1a;* type"text/css" 为默认可以不写 例子&#xff1a; 1 <!DOCTYPE html>2 <html>3 4 <head>5 <meta char…

【使用DIV+CSS重写网站首页案例】CSS浮动

CSS浮动&#xff1a; 浮动的框可以向左或向右移动&#xff0c;直到它的外边缘碰到包含框或另一个浮动框的边缘为止 由于浮动框不在文件的普通流中&#xff0c;所以文档的普通流中的块框表现得就像浮动框不存在一样。 选择器之 float属性: left&#xff1a;向左移动 right&#…

【使用DIV+CSS重写网站首页案例】CSS盒子模型

CSS盒子模型 取值问题&#xff1a; 默认情况&#xff0c;padding、border、margin都为0&#xff1b; 设定区域内容的width和height&#xff0c;是区域内容框的尺寸&#xff1b; 如果设定padding/border/margin&#xff0c;weight和height要减去相应值&#xff0c;保证总尺寸不变…

【使用DIV+CSS重写网站首页案例】步骤分析与代码实现

使用DIVCSS重写网站首页案例 步骤分析&#xff1a; 第一步&#xff1a;先定义一个大的 div&#xff08;整个页面&#xff09;&#xff0c;然后嵌套 8 个小的 div&#xff08;共八行&#xff09;&#xff1b;第二步&#xff1a;(第一行)在第一个 div 里面嵌套 3 个小的 div&…

简易网站栏目解决方案(附代码)

虽然是购物系统&#xff0c;但由于没有具体需求&#xff0c;只能多加几个诸如最新动态&#xff0c;精品推荐&#xff0c;近期公告&#xff0c;热点问答等小栏目上去凑数了&#xff01;为了能更高效的制作管理站点&#xff0c;经过多番思考设计了栏目及栏目类别关系模式&#xf…

zz.NET开发人员必知的八个网站

当前全球有数百万的开发人员在使用微软的.NET技术。如果你是其中之一&#xff0c;或者想要成为其中之一的话&#xff0c;我下面将要列出的每一个站点都应该是你的最爱&#xff0c;都应该收藏到书签中去。 对于不熟悉.NET技术的朋友&#xff0c;需要说明一下&#xff0c;.NET提供…

父级元素绑定定mouseout和mouseover,移过子元素是都会触发

2019独角兽企业重金招聘Python工程师标准>>> mouseover与mouseenter 不论鼠标指针穿过被选元素或其子元素&#xff0c;都会触发 mouseover 事件。 只有在鼠标指针从元素外穿入被选元素&#xff08;到元素内&#xff09;时&#xff0c;才会触发 mouseenter 事件。 mo…

一个绝佳的学习网站技术的网站——w3school

上个月无意中进入一个网站&#xff0c;看到里面还有挺多教程的&#xff0c;不管三七二十一&#xff0c;先收藏先。进去尝试一下w3school&#xff0c;感觉非常的棒。 首先它提供整套的网站架设技术的培训教程&#xff0c;从html->css->javaScript->php->SQL->.ne…

多家网站用户密码数据库被爆 下载地址及文件网络疯传

国内最大的程序员网站CSDN网站21日被曝600万用户的数据库信息被***公开&#xff0c;随后网上出现嘟嘟牛、7K7K、多玩网、178游戏网等多家网站也出现用户数据库泄露的消息。 用户数据库文件集合&#xff1a; CSDN-中文IT社区-600万.rar 104MB 多玩网_800W.rar 216MB 人人网500W_…