예제 #1
0
def distance(number1, number2):
    try:
        output = math.sqrt(math.square(number1 - number2))

        return (output)
    except:
        print("Invalid input")
예제 #2
0
def bsquare():
    try:
        ans=float(display.get())
        ans=math.square(ans)
        display.delete(0,END)
        display.insert(0,str(ans))
    except Exception:
        tkinter.messagebox.showerror("Value Error", "Check your values and operators")
예제 #3
0
    def calculate_variance(self):
        """Function to calculate the variance from the standard deviation.

        Args:
            None

        Returns:
            float: variance of the data set

        """

        self.variance = math.square(self.stdev)
        return self.variance
예제 #4
0
math.sqrt ( 16 )
math.log ( 16, 2 )  
math.cos ( 0 )
math.isnan(90)

# Importing Names from a Module Directly
#How to use specific functions from packages or modules in python 
from math import sqrt
sqrt ( 16 )


#How to use specific functions from packages or modules
#and also aliasing
from math import sqrt as square 
square ( 16 )

# How to find the function within the Module/Package
dir ( math )

help (math.sqrt)


 
#Slicing of strings

newstr = "Monty Python"

# Indexing using Left to Right

#START
예제 #5
0
def normalize(OO0OOO0OO0O00O0OO):  #line:128
    print(OO0OOO0OO0O00O0OO /
          (math.sqrt(math.mean(math.square(OO0OOO0OO0O00O0OO))) +
           1e-5))  #line:129
예제 #6
0
 def P(self):
     self.perimeter = self.side1 + self.side2 + (math.square(self.side1**2 +
                                                             self.side2**2))
def calculateSD(list,mean):
    if len(list) != 0:
        sumOfSquareError = 0.0
        for i in list:
            sumOfSquareError += math.square(i - mean)
        return math.sqrt(sumOfSquareError / len(list))
예제 #8
0
# Modules

# Import specific function in module under different name
from math import sqrt as square

print(square(4))
예제 #9
0
#from math import square
import math

for i in range(10):
    print(math.square(i))
예제 #10
0
def strong(x):  #przykład rekurencji: silnia
    if x == 1:
        return 1
    return x * strong(x - 1)


print(strong(6))


def fib(n):  #n-ty element ciągu fibonacciego metodą rekurencyjną
    if n == 0:
        return 0
    if n == 1:
        return 1
    if n == 2:
        return 1
    return fib(n - 2) + fib(n - 1)


print(fib(6))

import random  #import całego modułu/biblioteki
print(random.randint(1, 10))

from math import pi  #import konkretnej funkcji z modułu math
print(pi)

from math import sqrt as square  #import konkretnej funkcji z modułu math z nadaniem jej nowego aliasu obowiązującego w tym skrypcie
print(square(16))
예제 #11
0
def distance(p1, p2):
    return math.square((p1[0] + p2[0])**2 + (p1[1] - p2[1]**2))