关于python里面的问题,python2.7,V.b)怎么写
关于python里面的问题,python2.7,V.b)怎么写
IV.Making sure students are nice
The instructor always has to make sure that students behave well,and particularly that they don’t
cheat.The simplest way to check whether students could be cheating is when they get the same grade
on the assignment.You will write a function that takes as argument a list of grades.The function will
return “check!” when at least two grades are identical,and “ok” otherwise.For example,with the list
[3,6,5.5,2,6] we would see “check!”,and with [4,2,6,5] we would see “ok”.
a) Write a function cheatingSort that first sorts the list and then checks for identical grades by
using the fact that the list is sorted.
b) Write a function cheatingNoSort that solves the problem without sorting the list.
V.We must dispose of evil students
a) The instructor is very sad when he finds out that some students cheated on assignments.After
he hangs them,he needs a function removeEvilStudents that takes two arguments:a list of
grades,and the grade of the students who cheated.The function removes that grade from the
whole list,and returns the list.For example,[3,6,5.5,2,6] gets returned as [3,5.5,2].
b) Write a function howManyGroupsCouldCheat that takes a list of grades and returns how many
grades are identical.That function must use cheatingNoSort and removeEvilStudents.For
example,for the list [0,3,4,3,0,5] there are 2 identical grades:0 and 3 are repeated.
老师跟我说要用global,怎么用?