首页 > 其他分享 >5.18每日总结

5.18每日总结

时间:2023-05-18 21:45:11浏览次数:44  
标签:总结 key factors 每日 float score passed print 5.18

今日进行了python的学习。对于昨天的测试代码进行了分析学习。

R7-1 字典合并

d1 = eval(input())
d2 = eval(input())

for key in d2.keys():
    d1[key] = d1.get(key, 0) + d2[key]

t = list(d1.items())
t.sort(key=lambda x: ord(x[0]) if type(x[0]) == str else x[0])
out = str(dict(t)).replace(' ', '').replace("'", '"')
print(out)

R7-2 python-列表:统计考试成绩

score = list(input().split())
sum = 0
max_score = float(score[0])
min_score = float(score[0])
passed = 0
for i in range(0,len(score)):
    if float(score[i]) > max_score:
        max_score = float(score[i])
    if float(score[i]) < min_score:
        min_score = float(score[i])
    if float(score[i]) >= 60:
        passed = passed + 1
    sum = sum + float(score[i])
average = sum/len(score)
passed_rate = passed/len(score)*100
print("及格率:{:.1f}%".format(passed_rate))
print("平均分:{:.1f}".format(average))
print("最高分:{:.1f}".format(max_score))
print("最低分:{:.1f}".format(min_score))

R7-3 找出一个整数的所有素因子

def sushu(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

n = int(input())
factors = sushu(n)
print(','.join(map(str, factors)))

 

标签:总结,key,factors,每日,float,score,passed,print,5.18
From: https://www.cnblogs.com/louwangshayu/p/17413384.html

相关文章

  • 每日总结-23.5.18
    <%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd&qu......
  • 面向对象的编程(OOP)知识点总结
    软件构造期末考试将近,在此我将从OOP这一章节开始复习,记录下该章节中的重点内容。知识点概要:OOP基本概念:对象、类、属性、方法、接口和枚举OOP的独特特征:——封装与信息隐藏——继承与重写——多态、子类型、重载——静态与动态分派Java中一......
  • 5月18号今日总结
    今日代码:%定义目标函数f=@(x)100*(x(1)^2-x(2))^2+(x(1)-1)^2;%定义目标函数的梯度grad_f=@(x)[400*x(1)*(x(1)^2-x(2))+2*(x(1)-1);-200*(x(1)^2-x(2))];%定义终止准则epsilon=1e-5;%定义最大迭代次数max_iterations=1000;%初始点......
  • 每日打卡
    把真分数分解为埃及分数问题描述:古埃及人用的分数都是分子为一的分数,将真分数拆分成埃及分数问题分析:1如果分子为1直接输出2.分母是分子的倍数,化简后输出3.如果不能消去的话可以分出一个a/b+1和c出来代码:#include<stdio.h>intmain(){ longinta,b,c; printf("请输入a......
  • 5.18
    #include<iostream>usingnamespacestd;#include<string>classstudent{public:   voidshangke();protected:   stringname;   intbj;   intid;};classteacher{public:   voidjiaoke();protected:   intID;   intgz;};c......
  • 5.18总结
    packagecom.mf.jdbc.exmaple;importcom.alibaba.druid.pool.DruidDataSourceFactory;importcom.mf.jdbc.Brand;importorg.junit.Test;importjavax.sql.DataSource;importjava.io.FileInputStream;importjava.sql.Connection;importjava.sql.PreparedStatement;......
  • 每日总结2023-05-18
    今天对项目进行美化对于登录按钮,使用<?xmlversion="1.0"encoding="utf-8"?><ripplexmlns:android="http://schemas.android.com/apk/res/android"android:color="@color/mi_bai"><itemandroid:id="@+id/maske......
  • 5.18CSDN贪吃蛇
    贪吃蛇 速度不要调很慢会影响判断#include<iostream>#include<windows.h>#include<conio.h>#include<deque>#include<ctime>#include<stdexcept>usingnamespacestd;structSnake{//蛇类结构体charimage;shortx,y;//坐标};classsnakeGame......
  • 2023.5.18
    importosimportpandasaspd#添加测试数据os.makedirs(os.path.join('.','data'),exist_ok=True)data_file=os.path.join('.','data','house_tiny.csv')withopen(data_file,'w')asf:   f.write('N......
  • 5.18打卡
    一、问题描述:骰子是一个有六个面的正方体,每个面分别印有1~6之间的小圆点代表点数。假设这个游戏的规则是:两个人轮流掷骰子6次,并将每次投掷的点数累加起来。点数多者获胜;点数相同则为平局。要求编写程序模拟这个游戏的过程,并求出玩100盘之后谁是最终的获胜者。二、设计思路:由于每......