コード例 #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
ファイル: grading.py プロジェクト: dnordby/gradepy
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
ファイル: grading.py プロジェクト: dnordby/gradepy
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')
コード例 #7
0
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
ファイル: ImportModules.py プロジェクト: 2bdkid/Python-Notes
#!/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
ファイル: program.py プロジェクト: gopilinx/python_practice
def avgGrades():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)
        print(eachStudent, 'Avg Grade is ... ', avgGrade)
コード例 #16
0
ファイル: import syntax.py プロジェクト: ChrisW68/ClassWork
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
ファイル: course1_.py プロジェクト: Mikerhinos/Course1
def studentAVGs():
    for eachStudent in studentDict:
        gradeList = studentDict[eachStudent]
        avgGrade = m(gradeList)
    print(eachStudent,"has an average grade of",avgGrade)
    print(studentDict)
コード例 #20
0
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')
コード例 #25
0
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
ファイル: grades.py プロジェクト: shaynemeyer/python-pro
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
ファイル: Bab18.py プロジェクト: pujiarahman/Python-Basic
# 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
ファイル: grade.py プロジェクト: Nazgulbunny/PythonGrade
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)