Python-Take the highest and lowest scores to find the average

Hello everyone, I am Chen Feng, and this issue brings you Python-taking the highest and lowest scores to find the average

Table of contents

common writing

Advanced writing - ternary expression

Let's go after clicking three times, your support is my biggest motivation!


common writing

def exsum(lst):
    if len(lst)>2:
        return (sum(lst)-max(lst)-min(lst))/(len(lst)-2)
    else:
        return "打分人过少,不予打分"

Advanced writing - ternary expression

def exsum(lst):
    return (sum(lst)-max(lst)-min(lst))/(len(lst)-2) if len(lst)>2 else "打分人过少不予打分"

Let's go after clicking three times, your support is my biggest motivation!

Guess you like

Origin blog.csdn.net/gxlcf_516312/article/details/127344723