Home > other >  Python programming of grades
Python programming of grades

Time:09-22

20 known results in a list (please note that is not the dictionary, no name, only grade), please carry on the statistics, the output (100 ~ 90), (89 ~ 80), (79-60), bad (59 ~ 0) four level of number (enter the 20 grades at runtime, not programming)
For help.. !

CodePudding user response:

refer to the original poster and sank Milky Way you reply:
20 known results in a list (please note that is not the dictionary, no name, only grade), please carry on the statistics, the output (100 ~ 90), (89 ~ 80), (79-60), bad (59 ~ 0) four level of number (enter the 20 grades at runtime, not programming)
For help.. !

 
Def main (score_list) :
Better_count good_count, middle_count bad_count=0, 0, 0, 0
For score in score_list:
If score & gt;=90 and score & lt;=100:
Better_count +=1
Elif score & gt;=80 and score & lt;=89:
Good_count +=1
Elif score & gt;=60 and score & lt;=79:
Middle_count +=1
Elif score & gt;=0 and score & lt;=59:
Bad_count +=1
The else:
Print (' {with} for invalid results')
Print (' input results, optimal have {better_count} people, good people who are {good_count}, {middle_count} people, poor people who are {bad_count} ')

If __name__=="__main__" :
Quit_input_flag=1
Input_list=list ()
While quit_input_flag:
Score=eval (input (' please enter grades (please input end of the input q) : '))
If score not is' q:
Input_list. Append (score)
The else:
Quit_input_flag=0
The main (input_list)


Can consider, because it is on the phone code, there can be indented errors,

CodePudding user response:

reference 1st floor Hajo_ response:
Quote: refer to the original poster and sank Milky Way you reply:
20 known results in a list (please note that is not the dictionary, no name, only grade), please carry on the statistics, the output (100 ~ 90), (89 ~ 80), (79-60), bad (59 ~ 0) four level of number (enter the 20 grades at runtime, not programming)
For help.. !

 
Def main (score_list) :
Better_count good_count, middle_count bad_count=0, 0, 0, 0
For score in score_list:
If score & gt;=90 and score & lt;=100:
Better_count +=1
Elif score & gt;=80 and score & lt;=89:
Good_count +=1
Elif score & gt;=60 and score & lt;=79:
Middle_count +=1
Elif score & gt;=0 and score & lt;=59:
Bad_count +=1
The else:
Print (' {with} for invalid results')
Print (' input results, optimal have {better_count} people, good people who are {good_count}, {middle_count} people, poor people who are {bad_count} ')

If __name__=="__main__" :
Quit_input_flag=1
Input_list=list ()
While quit_input_flag:
Score=eval (input (' please enter grades (please input end of the input q) : '))
If score not is' q:
Input_list. Append (score)
The else:
Quit_input_flag=0
The main (input_list)


Can consider, because it is on the phone code, there can be indented error,

Thank you very much but want to ask is there a more concise way to do this problem

CodePudding user response:

refer to the second floor and sank Milky Way you reply:
Quote: refer to 1st floor Hajo_ response:
Quote: refer to the original poster and sank Milky Way you reply:
20 known results in a list (please note that is not the dictionary, no name, only grade), please carry on the statistics, the output (100 ~ 90), (89 ~ 80), (79-60), bad (59 ~ 0) four level of number (enter the 20 grades at runtime, not programming)
For help.. !

 
Def main (score_list) :
Better_count good_count, middle_count bad_count=0, 0, 0, 0
For score in score_list:
If score & gt;=90 and score & lt;=100:
Better_count +=1
Elif score & gt;=80 and score & lt;=89:
Good_count +=1
Elif score & gt;=60 and score & lt;=79:
Middle_count +=1
Elif score & gt;=0 and score & lt;=59:
Bad_count +=1
The else:
Print (' {with} for invalid results')
Print (' input results, optimal have {better_count} people, good people who are {good_count}, {middle_count} people, poor people who are {bad_count} ')

If __name__=="__main__" :
Quit_input_flag=1
Input_list=list ()
While quit_input_flag:
Score=eval (input (' please enter grades (please input end of the input q) : '))
If score not is' q:
Input_list. Append (score)
The else:
Quit_input_flag=0
The main (input_list)


Can consider, because it is on the phone code, there can be indented error,

Thank you very much but want to ask is there a more concise way to do this topic

In the main () function, temporarily haven't, but in the input list grades can be optimized, become like this

CodePudding user response:

reference Hajo_ reply: 3/f
Quote: refer to the second floor and sank Milky Way you reply:
Quote: refer to 1st floor Hajo_ response:
Quote: refer to the original poster and sank Milky Way you reply:
20 known results in a list (please note that is not the dictionary, no name, only grade), please carry on the statistics, the output (100 ~ 90), (89 ~ 80), (79-60), bad (59 ~ 0) four level of number (enter the 20 grades at runtime, not programming)
For help.. !

 
Def main (score_list) :
Better_count good_count, middle_count bad_count=0, 0, 0, 0
For score in score_list:
If score & gt;=90 and score & lt;=100:
Better_count +=1
Elif score & gt;=80 and score & lt;=89:
Good_count +=1
Elif score & gt;=60 and score & lt;=79:
Middle_count +=1
Elif score & gt;=0 and score & lt;=59:
Bad_count +=1
The else:
Print (' {with} for invalid results')
Print (' input results, optimal have {better_count} people, good people who are {good_count}, {middle_count} people, poor people who are {bad_count} ')

If __name__=="__main__" :
Quit_input_flag=1
Input_list=list ()
While quit_input_flag:
Score=eval (input (' please enter grades (please input end of the input q) : '))
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related