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:
 
,25,23,24,26,27,28,20,21,23,22,24,20,19,25,18,23,26,20,22 oldList=[12]
OldList. Remove (Max (oldList))
OldList. Remove (min (oldList))
Print (sum (oldList)/len (oldList))

CodePudding user response:

 
TestList=[12, 25, 23, 24, 26, 27, 28, 20, 21,
19, 22, 23, 24, 20, 25, 18, 23, 26, 80, 70]


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')


Print (findAverage (testList))
Print (findGroupAverage (testList, 60))

CodePudding user response:

refer to the second floor WilliamHuangSt response:
 
TestList=[12, 25, 23, 24, 26, 27, 28, 20, 21,
19, 22, 23, 24, 20, 25, 18, 23, 26, 80, 70]


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')


Print (findAverage (testList))
Print (findGroupAverage (testList, 60))


Ok, thank you, I look carefully again

CodePudding user response:

refer to the second floor WilliamHuangSt response:
 
TestList=[12, 25, 23, 24, 26, 27, 28, 20, 21,
19, 22, 23, 24, 20, 25, 18, 23, 26, 80, 70]


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')


Print (findAverage (testList))
Print (findGroupAverage (testList, 60))


I understand, really thank you very much

CodePudding user response:

refer to the second floor WilliamHuangSt response:
 
TestList=[12, 25, 23, 24, 26, 27, 28, 20, 21,
19, 22, 23, 24, 20, 25, 18, 23, 26, 80, 70]


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related