ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

【Python】第三章(容器)综合练习

2021-12-29 21:58:00  阅读:136  来源: 互联网

标签:容器 ch 第三章 index Python res scores print yr


scores = {"Zhang San": 45, "Li Si": 78, "Wang Wu": 40, \
         "Zhou Liu": 96, "Zhao Qi": 65, "Sun Ba": 90, \
         "Zheng Jiu": 78, "Wu Shi": 99, "Dong Shiyi": 60}
print(max(scores.values()))
print(min(scores.values()))
print(sum(scores.values())/len(scores))
print([k for k, v in scores.items() if v == max(scores.values())])

yr = int(input())
if (yr % 4 == 0 and yr % 100 != 0) or (yr % 400 == 0):
    print("闰年")
else:
    print("平年")

import random
x = [random.randint(1,100) for i in range(20)]
res = sorted(x[:10])+sorted(x[10:], reverse=True)
print(res)

import random
x = [random.randint(1, 100) for i in range(20)]
print(x)
x[::2] = sorted(x[::2], reverse=True)
print(x)

 

s = input()
res = [(ch, s.index(ch)) for ch in s if s.count(ch) == 1]  # 带空格
res1 = [(ch, s.index(ch)) for ch in s if s.count(ch) == 1 and ch != ' ']  # 不带空格

for ch, index in res1:
    print(ch, " ", index)

 

s = input()
res = [(ch, s.rfind(ch)) for ch in set(s)]
for ch, index in res:
    print(ch, " ", index)

from collections import Counter
s = input()
cnt = Counter(s).most_common()
for k, v in cnt:
    print(k, " ", v)

s = input()
if s == s[::-1]:
    print("Yes")
else:
    print("No")

import math
a = 10
b = 40
c = 15
det = b*b-4*a*c
if det > 0:
    res1 = (-b + math.sqrt(det)) / (2 * a)
    res2 = (-b - math.sqrt(det)) / (2 * a)
    print("{0:.2f} {1:.2f}".format(res1, res2))
elif det == 0:
    res = (-b) / (2 * a)
    print("{:.2f}".format(res))
else:
    print("无解")

total = 0
for yr in range(10):
    total = (total+1000)*(1+0.047)
print("{:.2f}".format(total))

from datetime import datetime
yr = datetime.now().year
mn = datetime.now().month
dy = datetime.now().day
print("{0:4d}-{1:2d}-{2:2d}".format(yr, mn, dy))

 

标签:容器,ch,第三章,index,Python,res,scores,print,yr
来源: https://blog.csdn.net/fftx_00/article/details/122223345

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有