Example #1
0
 def move(self, direction):
     s = self.delta * 100.0
     if direction == 0:
         self.position = m.add(self.position, m.scale(self.w, -s))
     elif direction == 1:
         self.position = m.add(self.position, m.scale(self.w, s))
     elif direction == 2:
         self.position = m.add(self.position, m.scale(self.u, s))
     elif direction == 3:
         self.position = m.add(self.position, m.scale(self.u, -s))
     self.view = None
Example #2
0
 def test_add_floats(self):
     """
     Test that the addition of two floats returns the correct
     result
     """
     result = mymath.add(10.5, 2)
     self.assertEqual(result, 12.5)        
Example #3
0
 def test_add_integers(self):
     """
     Test that the addition of two integers returns the
     correct total
     """
     result = mymath.add(1, 2)
     self.assertEqual(result, 3)
Example #4
0
 def test_add_strings(self):
     """
     Probar la suma de dos cadenas devuelve las dos cadenas como una
     cadena concatenada
     """
     result = mymath.add('abc', 'def')
     self.assertEqual(result, 'abcdef')
Example #5
0
 def test_add_strings(self):
     """
     Test the addition of two strings returns the two string as one
     concatenated string
     """
     result = mymath.add('abc', 'def')
     self.assertEqual(result, 'abcdef')
Example #6
0
 def test_add_days(self):
     """
     Test that the addition of two datetime objects returns the correct total
     """
     result = mymath.add(datetime.date.today(), datetime.timedelta(days=90))
     self.assertEqual(result,
                      datetime.date.today() + datetime.timedelta(days=90))
Example #7
0
def test_add_strings():
    """
    Test the addition of two strings returns the two string as one
    concatenated string
    """
    result = mymath.add('abc', 'def')
    assert result == 'abcdef'
 def test_add_strings(self):
     """
     Test the addition of two strings returns the two string as one
     concatenated string
     """
     result = mymath.add('abc', 'def')
     self.assertEqual(result, 'abcdef')
Example #9
0
 def test_add_floats(self):
     """
     Test that the addition of two floats returns the correct
     result
     """
     result = mymath.add(10.5, 2)
     self.assertEqual(result, 12.5)
Example #10
0
 def test_add_integers(self):
     """
     Test that the addition of two integers returns the
     correct total
     """
     result = mymath.add(1, 2)
     self.assertEqual(result, 3)
Example #11
0
    def test_add_strings(self):
        """
        Test the addition of two strings returns the two string as one
        concatenated string
        """
        result = mymath.add('abc', 'def')
        self.assertEqual(result, 'abcdef')
 
 
# if __name__ == '__main__':
#     unittest.main()
 def test_add_floats(self):
     result = mymath.add(10.2, 5)
     self.assertEqual(result, 15.2)
Example #13
0
import sys

# modify this path to match your environment
sys.path.append('C:\Users\mdriscoll\Documents')

import mymath

print(mymath.add(4,5))
print(mymath.division(4, 2))
print(mymath.multiply(10, 5))
print(mymath.squareroot(48))
Example #14
0
#!/usr/bin/env python3
import mymath

if __name__ == "__main__":
    res = mymath.add(3, 5)
    print("3 + 5 = {}".format(res))
import sys

# modify this path to match your environment
sys.path.append('C:\Users\mdriscoll\Documents')

import mymath

print(mymath.add(4, 5))
print(mymath.division(4, 2))
print(mymath.multiply(10, 5))
print(mymath.squareroot(48))
Example #16
0
import mymath

def log(msg):
    print "Msg logged: ", msg
mymath.reg_log(log)

print mymath.add(2.1, 3.2)
Example #17
0
 def test_add_strings(self):
     result = mymath.add("abc", "def")
     self.assertEqual(result, "abcdef")
Example #18
0
 def test_add_integers(self):
     result = mymath.add(1, 2)
     self.assertEqual(result, 3)
import mymath as mym  ## import module mymath.py created

x = 10
y = 15

print('Sum of %0.1f + %0.1f = %0.1f' % (x, y, mym.add(x, y)))
print('Diff of %0.1f - %0.1f = %0.1f' % (x, y, mym.diff(x, y)))
Example #20
0
import mymath
print("Resultado: %d." % mymath.add(5, 6))
Example #21
0
#-*- coding: utf-8 -*-

import mymath

print dir(mymath)
print mymath.mypi
print mymath.area(5)
print mymath.add(3,5)
Example #22
0
import sys
import mymath

# sys.path.append('/cafe24/PycharmProjects/python-modules')
# sys.path.append('../python-modules')

print(mymath.pi)
print(mymath.add(10, 20))
print(mymath.area_circle(10))
Example #23
0
def addsub(a, b):
    return mymath.subtract(mymath.add(a, b), b) == a
Example #24
0
import mymath


def addsub(a, b):
    return mymath.subtract(mymath.add(a, b), b) == a


def comparepower(a, b):
    return mymath.power(a, b) == mymath.intPower(a, b)


def incdec(a):
    return increment(decrement(a)) == a


assert mymath.add(3, 4) == 7
assert mymath.subtract(3, 4) == -1
assert mymath.power(4, 3) == 48
assert mymath.intPower(5, 3) == 125
assert mymath.increment(5) == 6
assert mymath.decrement(5) == 4

assert addsub(4, 2) == True
assert addsub(4324, 25345) == True

assert comparePower(3, 2) == True
assert comparePower(123, 5) == True

assert incdec(4) == True
assert incdec(234) == True
 def test_adding_on_windows(self):
     result = mymath.add(1, 2)
     self.assertEqual(result, 3)
Example #26
0
def test_add():
    assert mymath.add(2, 2) == 4
Example #27
0
def test(a, b, count):
    """Stupid test function"""
    mymath.add(a, b, count)
# from import
"""
We can import particular members of module by using from ... import .
The main advantage of this is we can access members directly without using module name.
"""

from mymath import x, add

print(x)  # 100
add(10, 20)  # The Sum: 30
# product(10, 20)  # NameError: name 'product' is not defined


# Note:
# We can import all members of a module by using --> from mymath import *


from mymath import *

print(x)  # 100
add(10, 20)  # The Sum: 30
product(10, 20)  # The Product: 200
Example #29
0
 def test_add_strings(self):
     result = mymath.add('abc', 'def')
     self.assertEqual(result, 'abcdef')
Example #30
0
def test_math():
    assert mymath.add(2, 3)  == 5
    assert mymath.div(6, 3)  == 2
    assert mymath.div(42, 1) == 42
    assert mymath.add(-1, 1) == 0
Example #31
0
import mymath as ma

print(ma.add(5, 9))
print(ma.diff(20, 9))
print(ma.mul(5, 5))
print(ma.divi(9, 3))
print(ma.pow(3, 5))
print(ma.modu(9, 2))
print(ma.diff(99, 22))
Example #32
0
File: package.py Project: za/py101
#!/usr/bin/python

import sys

sys.path.append('/home/za/dev/github/py101')

import mymath

print mymath.add(10,5)
print mymath.multiply(10,5)
print mymath.subtract(10,5)
print mymath.division(10,5)
 def test_add(self):
     result = mymath.add(2, 3)
     self.assertTrue(result is 5)
Example #34
0
 def test_add_floats(self):
     result = mymath.add(10.5, 2)
     self.assertEqual(result, 12.5)
Example #35
0
import mymath

x = 10.5
y = 20.5

z = mymath.add(x, y)

print("{0} + {1}  =  {2}".format(x,y,z))

Example #36
0
 def test_adding_on_windows(self):
     result = mymath.add(1, 2)
     self.assertEqual(result, 3)
Example #37
0
# Call module math
import mymath
import Animal as animal

# call function add from math.py
print(mymath.add(12,10))
number1 = 100
number2 = 200

print('Tong hai so la: ', mymath.add(number1,number2))

#Call animal class
animall = animal.animal()
animall.show()
animall.run()
animall.go()

# call dog class
dogAnimal = animal.dog('Lucy',4)
dogAnimal.show()
dogAnimal.run()
dogAnimal.go()

# call cat class
catAnimal = animal.cat('Bombi')
catAnimal.show()
catAnimal.run()
catAnimal.go()
catAnimal.roam()
Example #38
0
# logging03.py
import logging
import mymath

logging.basicConfig(
    level=logging.DEBUG,
    format='%(levelname)s:%(module)s(%(lineno)s):%(funcName)s:%(message)s')
logging.info('debug message')
mymath.add(2, 3)
Example #39
0
import mymath

mymath.add(10, 2)
Example #40
0
try:
    file = open('maria.txt', 'r')
except FileNotFoundError:
    print('file not found!')
else:
    s = file.read()
    file.close()

#
from mymath import arithmetic

arithmetic.add(1, 3)

import mymath

mymath.add(1, 3)
mymath.mean([1, 2, 3, 4, 5])

from mymath import pi

pi

#
joinstr_list = ['^(N_)?(\(주\)|주식회사|\(?주\)한무쇼핑|주\)|한무쇼핑\(주\))?(.*)(매장|-)', \
                '^(N_)?(\(주\)|주식회사|\(?주\)한무쇼핑|주\)|한무쇼핑\(주\))?(.*)']

id_list = ['로라메르시에', '엘리자베스아덴', '르라보', '킬리안', '하이코스', '비디비치', \
           '숨', '산타마리아노벨라', '오리진스', '라메르', '달팡', '그라운드플랜', '데코르테', \
           '동인비', '톰포드뷰티', '에르메스퍼퓸', '라페르바', '불리1803', '끌레드뽀보떼', 'RMK', '구딸파리', \
           '시슬리화장품', '지방시뷰티', '라프레리']
Example #41
0
# logging04.py
import logging
import mymath

logging.basicConfig(
    level=logging.DEBUG, 
    format='%(asctime)s:%(message)s',
    datefmt='%Y/%m/%d %H:%M:%S')
logging.info('debug message')
mymath.add(2,3)