import inf120stat as stat def choose_action(): #returns number from 1 to 5 print(""" ESP meny: 1. Les inn verdier 2. Tøm verdi listen 3. Vis gjennomsnitt og standardavvik 4. List ut verdiene 5. Avslutt Ditt valg:""") i = int(input()) if i not in range(1,6): raise ValueError() return i def read_values(values): while True: try: values.append(float(input('Ny verdi (Enter = slutt):'))) except ValueError: print('Verdier kan kunn være gyldige flyttall!') break return values def print_statistics(values): return(f'Antall verdier: {len(values)}, gjennomsnitt: {stat.mean(values):.2f}, standardavvik: {stat.std(values):.2f}') def main(): print('Starter Enkelt statistikk program (ESP)') values = [] while True: match choose_action(): case 1: # Write numbers read_values(values) case 2: values = [] case 3: #mean, std try: print(print_statistics(values)) except ZeroDivisionError: print('Tom liste!') case 4: print(values) case 5: exit('Hadebra :)') if __name__ == '__main__': main()