Note: your computation of the average is NOT correct:
for i in range(0, 6):
soma += sorteio()
extracts (and sums up)
6
values, while
media = soma / 5
divides by
5
.
Anyway, as already suggested by
Griff, consider rearranging your code for keeping track of the extracted values, e.g.
from random import *
def sorteio():
a = randint(0,5)
return a
def average(l):
sum = 0.0
for x in l:
sum = sum + x
return sum/len(l)
l = []
for i in range(0, 5):
l.append(sorteio())
print(l)
print("average ", average(l))
Then, standard deviation implementation should be straightforward.