Home > other > Consult! Python is really difficult!
Consult! Python is really difficult!
Time:10-17
Thank you god first!!!!!!
CodePudding user response:
This is very very simple questions, it is recommended that you spend half an hour to learn, just need to search on the Internet you can find a way, don't cheat you, you can definitely learn, Give you write a example:
Def findAverage (list) : List. Remove (Max (list)) List. Remove (min (list)) Return the sum (list)/len (list)
Def findGroupAverage (list, passLine) : SumPassGrade=sumFailGrade=0 SumPassNum=sumFailNum=0 For x in the list: If x & gt;=passLine: SumPassGrade +=x SumPassNum +=1 The else: SumFailGrade +=x SumFailNum +=1 If sumPassNum==0: Print (' All Fail ') Return sumFailGrade/sumFailNum Elif sumFailNum==0: Print (' All Pass) Return sumPassGrade/sumPassNum The else: Return sumPassGrade/sumPassNum sumFailGrade/sumFailNum
The import sys
Testdict={" William ":" 123456 "} Inputlist=[] While True: The line=sys. Stdin. Readline () strip () If the line==": Break Lines=line. The split () For the item in lines: Inputlist. Append (item)
If inputlist [0] in testdict. Keys () : If testdict [inputlist [0]]==inputlist [1] : Print (' landing successful ') The else: Print (' user and password errors') The else: Print (' user and password errors')