栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python 几道题目的代码。

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python 几道题目的代码。

num=int(input())
remainder=num%13
print(remainder)

num=input()
print(num[-4:])

nums=[10,8,2,5,6,7,3,1,9,0]
x=eval(input())
nums.append(x)
num=max(nums)
print(num)

import math
e=math.e

a,b,c,d=map(float,input().split(','))


y=a**3+b**3+c**3+d**3
y=math.sqrt(y)
y=y/e
print('y={:.5f}'.format(y))

import math
x=int(input())

if x<=-2:
    y=3+math.cos(x)
elif x<=3:
    y=math.fabs(x-2)
else:
    y=2-x**2

print('y={:.2f}'.format(y))


n = int(input())
sum = 0
for i in range(2, n + 1, 2):
    sum += i
print("2到{}的偶数数列和是{:.2f}".format(n, sum))

def count(s):
    cnt=0
    for c in s:
        if c.isupper():
            cnt +=1
    return cnt

s=input()
cnt=count(s)
print('字符串中包含{}个大写字母'.format(cnt))

import random

seed = int(input())
random.seed(seed)

lis = []
for i in range(20):
    a = random.randint(0, 100)
    lis.append(a)

print(lis)

maxscore = max(lis)
avgscore = sum(lis) / len(lis)

a = max(lis)
lis.remove(a)
b = max(lis)
lis.remove(b)
c = max(lis)
lis.remove(c)
print('最高分为{}'.format(maxscore))
print('平均分为{}'.format(avgscore))
print('前三名成绩分别为{}、{}和{}'.format(a, b, c))

f = open('phonenum.txt', 'r')

dic = {}
while 1:
    line = f.readline()

    if not line:
        break
    name, phone = line.split(' ')
    dic[name] = phone.split('n')[0]

name = input()

if name in dic:
    print('{}:{}'.format(name, dic[name]))
else:
    print('数据不存在')

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1001261.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号