Python123

1.

def max2(x):
    # write your code here...
    ls_x=list(x)
    m1 = max(ls_x)
    ls_x.remove(max(ls_x))
    m2 = max(ls_x)
    return (m2,m1)


ls = eval(input())
print(max2(ls))

2.import math
r=float(input())
r=float(r)
S=math.pi*r**2
print('{:.2f}'.format(S))

3.def midnum(ls):
    ls.sort()
    s=len(ls)
    if s%2==0:
        i=(s-1)//2
        mid=(ls[i]+ls[i+1])/2
    else:
        i=s//2
        mid=ls[i]
    return mid
ls=list(eval(input()))
print(midnum(ls))

4.

def countlevels():  
    #write your code here...
    x=7
    while True:
       x=x+7
       if x%2==1 and x%3==2 and x%5==4 and x%6==5:
           break
    return x
    

print(countlevels())

5.

import math
a, b = eval(input())  

# 请在此添加代码,要求判断是否存在两个整数,它们的和为a,积为b  
def judge(a,b):
    for  i in range(max(a,b)):
        for j in range(max(a,b)):
            if i+j==a and i*j==b:
                return "Yes"
    return"No"
print(judge(a,b))

6.

from math import sqrt

class Point:
    def __init__(self, x=0, y=0):
    ##### write your codes here...
      self.x=x
      self.y=y

    def is_first_quadrant(self):
    ##### write your codes here...
      if self.x>=0 and self.y>=0:
        return True
      else :
        return False

    def __str__(self):
    ##### write your codes here...
      return f'({self.x},{self.y})'

    def distance(self, other):
    ##### write your codes here...
      return ((self.x-other.x)**2+(self.y-other.y)**2)**(1/2)


p1 = Point(0, 0)
p2 = p2 = Point(3,4)
print(p2)  ##输出(3,4)
print(p2.is_first_quadrant())  ##输出True
print(p1.distance(p2))  ##输出5.0

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

晶bling

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

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

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

打赏作者

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

抵扣说明:

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

余额充值