Пример #1
0
    def part3():

        from statistics import mean as m

        x = m(example_list)

        print("3 The mean is: ", x)
Пример #2
0
 def confidence(self,features):
     votes=[]
     for i in self._classifiers:
         v=i.classify(features)
         votes.append(v)
     
     choice_votes=votes.count(m(votes))
     conf=float(choice_votes)/len(votes)
     return conf
Пример #3
0
    def part5():
        from statistics import mean as m, stdev as s, variance as v

        x = m(example_list)

        print("5 The mean is: ", x)

        y = s(example_list)
        print("5 standard div si: ", y)

        z = v(example_list)
        print("5 Variance is: ", z)
Пример #4
0
def classAverage():
    query = "SELECT * FROM student"
    results = cursor.execute(query).fetchall()
    averageList = []

    if results:
        for record in results:
            grades = json.loads(record["grades"])
            averageList += grades
        print('Class average grade:', m(averageList))
        prompt('\n\nPlease select another action:')
    else:
        prompt('You have no students in the class!')
Пример #5
0
def studentAverage():
    firstName = input('Student first name: ')
    lastName = input('Student last name: ')

    query = "SELECT * FROM student WHERE first='" + firstName.lower(
    ) + "' AND last='" + lastName.lower() + "'"
    results = cursor.execute(query).fetchall()

    if results:
        for record in results:
            grades = json.loads(record["grades"])
            print('Student average grade:', m(grades))
            prompt('\n\nPlease select another action:')
    else:
        prompt(
            '\n\nThat student does not exist! Please select another action:')
 def studentAVG():
     for eachStudent in studentDict:
         gradelist = studentDict[eachStudent]
         avgGrade = m(gradelist)
         print(eachStudent, 'has an average of  : avgGrade')
import statistics
lista = [1, 5, 2, 6, 4, 2, 6, 5, 4, 52, 1, 5, 2, 5, 6, 1]
print(statistics.mean(lista))
# wow moduł liczy na średnią z liczb zawartych w liście!
# to jest podstawowy sposób importowania modułów, ale istnieje wiele więcej

# dobra, to teraz kolejny sposób

import statistics as s  # teraz cały moduł ukryty jest pod literą {
print(s.mean(lista))

# możesz importować tylko niektóre funkcje z danego moduły, żeby nie zapychać pamięci
from statistics import mean
print(mean(lista))

# i teraz użyć odpowiedniego skrótu
from statistics import mean as m
print(m(lista))

# mozemy importować kilka funkcji
from statistics import mean as m, median as d
print(m(lista))
print(d(lista))

# możemy zaimportować także wszsytkie funkcje z danego modułu i wedy wywołując
# poszczególne funkcje nie trzeba wpisywać nazwy biblikoteki

from statistics import *
print(mean(lista))
print(variance(lista))
Пример #8
0
exList = [5,2,3,7,8,9,4,5,6,1,0,3,5]

import statistics as s
print(s.mean(exList))
print(s.median(exList))
print(s.mode(exList))
print(s.stdev(exList))
print(s.variance(exList))

from statistics import mean
print(mean(exList))

from statistics import mean as m
print(m(exList))

from statistics import mean, stdev
print(mean(exList), stdev(exList))

from statistics import mean as m, stdev as sd
print(m(exList), sd(exList))

from statistics import *
print(mean(exList), stdev(exList))
Пример #9
0
import moduleExample as epic
import statistics as st

from statistics import variance
from statistics import mean as m

epic.epic()

print(st.mean([1, 2, 3, 4, 5]))
print(m([1, 2, 3, 4, 5]))
print(variance([1, 2, 3, 4, 5, 6, 7, 8]))
Пример #10
0
Use this.
Imports the module X, and creates a reference to that module in the current namespace. Or in other words, after you’ve run this statement, you can use X.name to refer to things defined in module X.
"""
from X import *

"""
Do not use this. Namespace pollution
After you’ve run this statement, you can simply use a plain name to refer to things defined in module X. But X itself is not defined, so X.name doesn’t work.
"""
from X import a, b, c

"""
You can now use a and b and c in your program. But not X.a or X.d.
"""

import X as s

"""
This will allow you to basically rename the module to whatever you want. People generally do this to shorten the name of the module. Matplotlib.pyplot is often imported as plt and numpy is often imported as np, for example.
"""
from statistics import mean as m

"""
Same as above but with the functions/objects
"""

from statistics import mean as m, median as d

print(m(example_list))
print(d(example_list))
Пример #11
0
import statistics as s  # This will be helpful when we don't want to write statistics as a whole, instead we can replace it with s just so that it becomes handy

data = [2, 3, 4, 5, 5, 6, 7, 8, 99, 67]
v = s.variance(data)
print(v)

# Now let's suppose we don't even wan't to use s.mean, we wan't to use only mean , for that
from statistics import mean
print(mean(data))

# let's just say you don't want to type mean also , then use
from statistics import mode as m
print(m(data))

#   we can also combinely import the functions
from statistics import median as M, mode as m

#    let's just say that we need to import everything, for that
from statistics import *
#    so in this way we don't actually need to use modeuleName.functionName()
Пример #12
0
def gradeAvgStudent():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)
    print(eachStudent, 'has average grade of', avgGrade)
Пример #13
0
#!/usr/bin/env python3

from statistics import mean as m

print(m([3,3,2,3]))
Пример #14
0
exList = [5,6,2,1,6,7,2,2,7,4,7,7,7]

print("LONG WAY:\n"
      "import statistics\n"
      "exList = [5,6,2,1,6,7,2,2,7,4,7,7,7]\n"
      "print(statistics.mean(exList))")
## print(s.mean(exList))

print("\nOPTIONAL WAY:\n"
      "import statistics as s\n"
      "print(s.mean(exList))")
## print(s.mean(exList))

print("\nOPTIONAL WAY:\n"
      "from statistics import mean\n"
      "print(mean(exList))")
## print(mean(exList))

print("\nOPTIONAL WAY:\n"
      "from statistics import mean as m\n"
      "print(m(exList))")
print(m(exList))

print("\nOTHER OPTIONS:\n"
      "from statistics import mean, stdev <- can just rev these 2 fcns\n"
      "from statistics import mean as m, stdev as s <- can just rev these 2 fcns as m. and s.\n"
      "from statistics import * <- can just rev the fcns w/o prefix\n"
      "")

separator()
Пример #15
0
def avgGrades():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)
        print(eachStudent, 'Avg Grade is ... ', avgGrade)
Пример #16
0
from statistics import mean as m, stdev as s
#import statistics as s

exList = [8,4,6,12,48,125,122,4,58,7,1,2,68]

#print(s.mean(exList))
print('The mean is: ', m(exList))
print('The standard deviation is: ',s(exList))


import statistics as s

exList = [8,4,6,12,48,125,122,4,58,7,1,2,68]

print('The standard deviation is: ',s.mean(exList))
Пример #17
0
#from statistics import *
from statistics import stdev as sd, mean as m

example_list = [3, 5, 7, 8, 23, 2, 5, 3, 51, 52, 626, 62, 623]

x = sd(example_list)
print(x)

x = m(example_list)
print(x)
'''
import statistics as s

example_list = [3,5,7,8,23,2,5,3,51,52,626,62,623]

x = s.mean(example_list)
print(x)

x = s.median(example_list)
print(x)

x = s.stdev(example_list)
print(x)

x = s.variance(example_list)
print(x)

'''
Пример #18
0
def avgGrade():
    print('\nThe average grade of each student is: ')
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)
        print('Average grade of: ',eachStudent,' is: ',avgGrade)
Пример #19
0
def studentAVGs():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)
    print(eachStudent,"has an average grade of",avgGrade)
    print(studentDict)
def eleveMoy():
    for chaqueEleve in eleveDict:
        listeNote = eleveDict[chaqueEleve]
        moyNotes = m(listeNote)

        print(chaqueEleve,'a une moyenne de: ',moyNotes) 
Пример #21
0
def eleveMoy():
    for chaqueEleve in eleveDict:
        listeNote = eleveDict[chaqueEleve]
        moyNotes = m(listeNote)

        print(chaqueEleve, 'a une moyenne de: ', moyNotes)
Пример #22
0
def median(data: List[int]) -> [int, float]:
    return m(data)
Пример #23
0
def calculateAvgs():
    for eachStudent in studentDic:
        gradeList = studentDic[eachStudent]
        avgGrade = m(gradeList)
        print(eachStudent, 'Average Grade = ', avgGrade)
Пример #24
0
#Author: Manuel Garcia Lopez

#Modules import
import statistics as s  #we can create an alias for each of our imports
#also we can import everything in another way
from statistics import *
#we can also just import the thing we want from the proper import
from statistics import mean
#we could even say the following using another alias
from statistics import stdev as st
#or just import several functions form one module in one single time with alias
from statistics import median as m, median_low as ml

sample_list = [1, 2, 3, 4, 5, 23, 56, 6, 7, 8, 9]

variance = s.variance(sample_list)
mean1 = mean(sample_list)
stdev1 = st(sample_list)
median = m(sample_list)
medianl = ml(sample_list)

print(variance)
print(mean1)
print(stdev1)
print(median)
print(medianl)

#Using our own modules
import ModulesCreation

ModulesCreation.ex('test')
list = [2, 3, 4, 5, 6, 8, 9, 8, 4]
x = s.variance(list)
#! or

from statistics import variance
list = [2, 3, 4, 5, 6, 8, 9, 8, 4]
y = variance(list)

#! or

from statistics import variance as v
list = [2, 3, 4, 5, 6, 8, 9, 8, 4]
z = v(list)

#! or
from statistics import variance, mean
list = [2, 3, 4, 5, 6, 8, 9, 8, 4]
t = variance(list)
m = mean(list)

#! or
from statistics import variance as v, mean as m
list = [2, 3, 4, 5, 6, 8, 9, 8, 4]
p = v(list)
q = m(list)
#! or
from statistics import *
list = [2, 3, 4, 5, 6, 8, 9, 8, 4]
a = variance(list)
b = mean(list)
Пример #26
0
def student_AVGs():
    for eachStudent in gradeDict:
        gradeList = gradeDict[eachStudent]
        avgGrade = m(gradeList)
        print(eachStudent, 'has an average grade of', avgGrade)
Пример #27
0
print('Hello ', name)
"""
##import statistics
##
##exList = [5,4,3,2,6,3]
##x = statistics.mean(exList)
##print(x)
##
##x = statistics.median(exList)
##print('median', x)
##
##x = statistics.mode(exList)
##print('mode', x)
##
##x = statistics.stdev(exList)
##print('stdev', x)
##
##x = statistics.variance(exList)
##print('variance', x)

#import syntax
# from statistics import mean as m, stdev as s
from statistics import mean as m
##import statistics as s
myList = [3, 4, 7, 8, 3, 1]
##print(s.mean(exList))
print('stat mean import syntx', m(myList))

# if you want all
# from statistics import *
Пример #28
0
def avgGrade():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        average = round(m(gradeList), 2)

        print(eachStudent, 'has an average grade of: ', average)
Пример #29
0
# import statistics
# import statistics as s
# from statistics import mean,stdev
# from statistics import *
from statistics import mean as m, stdev as s

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]
# print(statistics.mean(x))
# print(s.mean(x))
# print(mean(x))
# print(stdev(x))
print(m(x))
print(s(x))
Пример #30
0
def studentAvg():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)
        print(eachStudent,': ',avgGrade)
Пример #31
0
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 14 14:39:31 2016
Objective: impoting module syntax
@author: jatan.sharma
"""

example_list = [5, 2, 5, 6, 1, 2, 6, 7, 2, 6, 3, 5, 5]

# Basic Importing
import statistics
print(statistics.mean(example_list))

# Sometimes, however, you will see people use the "as" statement in their imports. This will allow you to basically rename the module to whatever you want. People generally do this to shorten the name of the module. Matplotlib.pyplot is often imported as plt and numpy is often imported as np
import statistics as s
print(s.mean(example_list))

#You can just import each function within the module you plan to use
from statistics import mean

# so here, we've imported the mean function only.
print(mean(example_list))

# and again we can do as
from statistics import mean as m
print(m(example_list))

from statistics import *
print(mean(example_list))
Пример #32
0
def calcola_media(lista):
    return m(lista)
Пример #33
0
def studentsAvgs():
	for eachStudent in students:
		gradeList = students[eachStudent]
		avgGrade = m(gradeList)

		print(eachStudent, "has an average grade of:" , avgGrade)
Пример #34
0
def gradeAverage():
    for student in studentDatabase:
        gradeList = studentDatabase[student]
        avg = m(gradeList)

        print(student, "has a grade average of", avg)
Пример #35
0
def findStudentAverage():
    print("finding student average")
    for eachStudent in studentGrades:
        gradeList = studentGrades[eachStudent]
        average = m(gradeList)
        print(eachStudent, "average is", average)
Пример #36
0
print(x)

x = statistics.mode(exList)
print(x)

x = statistics.stdev(exList)
print(x)

print(statistics.variance(exList))

# other forms of import

import statistics as s
exList = [5, 2, 3, 1, 2, 3]

print(s.mean(exList))

from statistics import mean
print(mean(exList))

from statistics import mean as m
print(m(exList))

from statistics import mean as m, stdev as s
print(m(exList))
print(s(exList))

from statistics import *
print(mean(exList))
print(stdev(exList))
Пример #37
0
def studentAVGs():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)

        print(eachStudent,'has an average grade of:',avgGrade)
Пример #38
0
def studentAverages():
    for eachStudent in studentDict:
        gradelist = studentDict[eachStudent]
        averageGrades = m(gradelist)
        print(eachStudent,'has an average of grade is: ',averageGrades)
Пример #39
0
def StudentAverage():
    for eachstudent in studentDict:
        gradelist = studentDict[eachstudent]
        avgGrade = m (gradelist)
        print (eachstudent , 'has an average grade of :', gradelist)
Пример #40
0
 def classify(self,features):
     votes=[]
     for i in self._classifiers:
         v=i.classify(features)
         votes.append(v)
     return m(votes)