tags: python
There is a file PY202.py in the candidate's folder. This file is the code prompt framework for this topic, and the code can be modified at will. Please write code in this file to achieve the following functions
Use the keyboard to input information such as the name of the course that Xiao Ming studied and test scores. The information is separated by spaces, one line for each course, and a blank line to end the entry. Example
The format is as follows
Mathematics 90
Language 95
Yangyu 86
Physics 84
Biology 87
The screen outputs the course and grade with the highest score, the course and grade with the lowest score, and the average score (with 2 decimal places).
Note that the comma is an English comma, and the format is as follows
The highest score course is 95 for Chinese, the lowest score is 84 for physics, and the average score is 88. 40
Tip: It is recommended to use the python integrated development environment IDLE provided by this machine to write, debug and verify programs.
data = input() # Course name Test score
d={}
while data:
t=data.split()
d[t[0]]=t[1]
data = input()
ls=list(d.items())
ls.sort(key=lambda x:x[1],reverse=True)
s1,g1=ls[0]
s2,g2=ls[len(ls)-1]
a=0
for i in d.values():
a=a+int(i)
a=a/len(ls)
print("The highest-scoring course is {} {}, the lowest-scoring course is {} {}, and the average score is {:.2f}".format(s1,g1,s2,g2,a))
(Please combine the "Higher Education version of the Python language programming design sprint paper (including the online question bank)") . 1.1.1 Python language basic syntax elements Test...
Today, I understand some of the basic elements of Python through a temperature-conversion ten code. The so-called temperature conversion is the conversion of degrees Celsius and Fahrenheit. You can ou...
About python's web framework mainstream There is a more comprehensive django is mainly developed without knowing the sql statement can interact with the database and django has its own background mana...
Today I brought two simple applications of IfcOpenShell-Python that I wrote. The code is all made by myself. I remember that if you use C# to call the REVIT API, you need at least dozens of lines of c...
The topic is roughly like this: Draw five circles of random sizes, the horizontal and vertical coordinates are controlled at (-100, 100), and the color is randomly selected. The color is already given...
Fibo Nachi (from recursive, to optimize recursive, to iteration) Compressed character “ATG” 24bits => 001110 6bits Unbreakable encryption Calculating PI π = 4/1 - 4/3 + 4/5 - 4/7 + 4...
Question 1: Write a program to count the Chinese characters and punctuations that appear in this "Tianlong Babu" text, separate the characters and the number of occurrences with a colon:, an...
There are two Python source files in the candidate's folder, corresponding to two questions, please follow the instructions in the file to modify the code to achieve the following functions: The follo...