赞
踩
目录
*如有错误请私聊纠正
- n=int(input())
- # 每日打洞量,所需天数
- big,small,day,time=1,1,0,1
- # 各自总共打洞量
- distance_of_big,distance_of_small=0,0
- # 洞未打完 循环
- while n>0:
- # 第一天打完的情况单独考虑
- if n-big-small<0:
- time=n/(big+small)
- # 剩余洞长
- n=n-big-small
- distance_of_small=distance_of_small+small*time
- distance_of_big=distance_of_big+big*time
- big*=2
- small*=0.5
- day=day+1
- print(day)
- print(round(distance_of_small,1),round(distance_of_big,1))
- def say_hi_multi_parameter(*names): # 括号里填空
- """定义一个不定参数传递函数,可接收不限数量的参数。"""
- for name in names: # 遍历输出,观察结果
- print(name+",你好!")
-
-
- say_hi_multi_parameter('孟浩然')
- say_hi_multi_parameter('杜甫', '李白', '柳宗元', '李商隐')
- x, n = input().split()
- x = int(x)
- n = int(n)
- answer = x
- if n == 0:
- answer = 1
- elif n == 1:
- answer = x
- else:
- for i in range(n - 1):
- answer= answer * x
-
-
- print(answer)
- def say_hi_gender(full_name, gender):
- """定义一个名为say_hi_gender的有参数函数,
- 根据性别gender值确定称谓,男性称为“先生”,女性称为“女士”,不确定性别时称为“先生/女士”
- 返回值为替换了姓名与称谓的欢迎字符串
- 例如:尊敬的李白先生,欢迎来到火星!"""
- if gender =="男":
- return f"尊敬的{full_name}先生,欢迎来到火星!"
- elif gender =="女":
- return f"尊敬的{full_name}女士,欢迎来到火星!"
- else:
- return f"尊敬的{full_name}先生/女士,欢迎来到火星!"
- #=======================================================
- #=======================================================
-
-
- # 函数名作为print()函数的参数,输出say_hi_gender()的返回值
- person_name = input() # 输入人名,如输入:李白
- person_gender = input() # 输入性别,如输入:男
- print(say_hi_gender(person_name, person_gender)) # 调用函数,输出函数的返回值
- def selfDivisor(num):
- t=str(num)
- if '0' in t:
- return 0
- for i in t:
- if num%int(i)!=0:
- return 0
- return 1
-
- n=int(input())
- ls=[]
- for i in range(1,n+1):
- if selfDivisor(i):
- print(i,end=" ")
- def isPrime(n):
- for i in range(2,int(n/2)):
- if n%i == 0:
- return False
- break
- return True
- a = int(input())
- i = a
- while i >= 2:
- if isPrime(i):
- print (i)
- break
- i-=1
- n=eval(input())
- n=n+1
- s=0
- for i in range(1,n):
- s=s+i*i
- print(s)
- def fun(n):
- #在前两个月兔子的对数都为1
- if n <= 2:
- return 1
- else:
- # 由数据的规律可知,第三个数的结果都是前两个数之和,所以进行递归叠加
- return fun(n-1) + fun(n-2)
- #获取输入的月数
- num = int(input())
- #计算前一个月和后一个月的比值
-
- match = fun(num-1)/fun(num)
- match = round(match, 4)
- match = ("%.4f" % match)
- #print(match)
- match = str(match).split(".")[0] + "." + str(match).split(".")[1][:3]
- #
- print(f"{fun(num)} {match}")
- import math
-
-
- def cutting_circle(times): # times为分割次数
- side_length = 1 # 初始边长
- edges = 6 # 初始边数
- def f(x): ## 由当前边长,求割后边长
- h = 1 - math.sqrt(1 - (x / 2) ** 2)
- return math.sqrt(h ** 2 + (side_length / 2) ** 2)
-
- for i in range(times):
- side_length = f(side_length)
- edges *= 2
- pi = edges*side_length/2
-
- return edges, pi
-
-
- if __name__ == '__main__':
- times = int(input()) # 割圆次数
- print('分割{}次,边数为{},圆周率为{:.6f}'.format(times, *cutting_circle(times))) # 圆周率
- print('math库中的圆周率常量值为{:.6f}'.format(math.pi))
-
- a,b=map(int,input().split(','))
- ans=0
- if a>15:
- ans+=(a-15)*2.3*1.5
- a=15
- if a>3:
- ans+=(a-3)*2.3
- a=3
- ans+=13
- ans+=b
- print(int(ans))
- n=int(input())
-
- sum=0
-
- fz=2
-
- fm=1
-
- for i in range(n):
-
- sum=sum+fz/fm
-
- fm,fz=fz,fz+fm
-
- print(sum)
- def isPrime(n): # 定义判断素数的函数
- for i in range(2,int(n**0.5)+1):
- if n%i==0:
- return 0
- return 1
-
- num = int(input()) # 接收用户输入并转成整数
- for i in range(2,num+1):
- if isPrime(i)==1:
- print(i,end=' ')
说明:此题目来自【Python123】,答案为自己创作,不产生任何商业利益,如有侵权,请联系删除。Python123 - 编程更简单Python123 是面向新工科教学需求的计算机类基础课程教学辅助平台。支持全国计算机二级 python 考试自学与备考,还向合作教师与高校提供精品教学资源、全系列课程内容、全流程教学工具,支撑课程教学管理、练习、考试、教学研究等实际需求,为国家级、省部级一流课程提供教学研究数据支撑。https://python123.io/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。