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

        print("Testing Add Function")
        self.assertEqual(myMath.add(10, 5), 15)
        self.assertEqual(myMath.add(10, 20), 30)
        self.assertEqual(myMath.add(30, -20), 10)
        self.assertEqual(myMath.add(-1, -1), -2)
        self.assertEqual(myMath.add(0, 0), 0)
        print("Add Tests Passed\n")
Пример #2
0
def main():
    import sys
    nums = sys.argv[1]
    nums = map(int, nums.split(','))
    maxNum = m.maximum(nums)
    minNum = m.minimum(nums)
    print "The difference is:%d " % (m.subtraction(maxNum, minNum)),
    print "The summation is:%d " % (m.add(maxNum, minNum)),
    print "The summation of all input is:%d " % (m.sumTotal(nums)),
    print "The number of even numbers is:%d " % (len(m.evenNum(nums))),
    if minNum < 5:
        nums = m.clear(nums)
    print "The values in the list are: %s " % (str(nums)),
Пример #3
0
def handel_opeartion(math_operation, num1, num2):
    """ 
     This function does arethmatic operation.
     math_opeartion -> [+, -, *, /], R for main menu return
     num1= first number
     num2= second number 
     """
    if (math_operation not in math_operationsDict):
        print("-" * 50)
        print("Wrong Choice! Please try again.")
        print("-" * 50)
    elif math_operation == "+":
        print("{} + {} = {}".format(num1, num2, myMath.add(num1, num2)))
    elif math_operation == "-":
        print("{} - {} = {}".format(num1, num2, myMath.subtract(num1, num2)))
    elif math_operation == "*":
        print("{} * {} = {}".format(num1, num2, myMath.multiply(num1, num2)))
    elif math_operation == "/":
        print("{} / {} = {}".format(num1, num2, myMath.divide(num1, num2)))
    else:
        print_dictionary("Welcome to the main menu", **math_operationsDict)
def calculator(x):
    maxMinusMin = myMath.subtraction(myMath.maximum(x), myMath.minimum(x))
    sumMaxMin = myMath.add(myMath.maximum(x), myMath.minimum(x))

    intList = [int(i) for i in x]

    sumOfList = myMath.sumTotal(intList)
    evenNos = myMath.evenNum(intList)

    checkSmallest = myMath.minimum(intList)

    if checkSmallest < 5:
        clearedList = myMath.clear(intList)

    else:
        clearedList = intList

    print("The difference is:%d" % maxMinusMin +
          " The summation is:%d" % sumMaxMin +
          " The summation of all input is:%d" % sumOfList +
          " The number of even numbers is:%d" % evenNos +
          " The values in the list are:",
          end=" ")
    print(clearedList)
Пример #5
0
import myMath

print(myMath.add(10, 20))
Пример #6
0
import sys

# modify path to match our environment
sys.path.append('/home/tomasdem/repos/samplePythonPackage/samplePythonPackage')

#from myMath import *
import myMath


#print(myMath.adv.sqrt(4))
print(myMath.add(2, 4))
Пример #7
0
import myMath

myMath.add(10,20)
myMath.minus(20,10)
myMath.mult(10,20)
myMath.div(20,10)
Пример #8
0
# own modules
import myMath # me trae todas las funciones o variables que esten en ese archivo
print(myMath.PI)
myMath.add(1, 2)
myMath.substract(2, 1)

 # otra forma de importar. Traemos los metodos directamente
 # sin la necesidad de especificar 
from myMath import add, substract, PI
print(PI)
add(1, 2)
substract(2, 1)

# python modules
import datetime
print(datetime.date.today())
print(datetime.timedelta(minutes=70))

 # otra forma de importar. Traemos los metodos directamente
 # sin la necesidad de especificar 
from datetime import timedelta, date
print(date.today())
print(timedelta(minutes=80))


# thirdy party modules
# 1. install python3-pip and python-php with apt
# 2. install colorama using pip install colorama
from colorama import Fore, Style 

print(Fore.RED + 'Hello world')
Пример #9
0
#todo Own modules
#todo thirdy party modules
#todo python modules

#* Módulos pre-construido desde python

import datetime
import myMath  # importando módulo propio.

#from datetime import timedelta, importa la función timedelta.

print(datetime.date.today())
print(datetime.timedelta(minutes=60))

myMath.add(2, 3)  #Impporte método del módulo myMath

#Todo instalar módulos de terceros.
#*Escribir en la consola, la instrucción: pip install + <nombre del modulo>

from colorama import Fore, Style  #*Especifica los módulos que se utilizaran en el proyecto.

print(Fore.RED + "Hello World")
Пример #10
0
from TreeTaggerWrapper import treetaggerwrapper
#1) build a TreeTagger wrapper:
tagger = treetaggerwrapper.TreeTagger(TAGLANG='en',TAGDIR='D:/Programme/TreeTagger')
#2) tag your text.
tags = tagger.TagText("This is a very short text to tag.")
#3) use the tags list... (list of string output from TreeTagger).
print tags

   
# Check, whether the format of the tagged postings is good for the tagged corpus reader
# p.51 NLTK Cookbook
input_directory = path
from nltk.corpus.reader import TaggedCorpusReader
reader = TaggedCorpusReader(input_directory, r'.*\.txt')
reader.words()
# ['The', 'expense', 'and', 'time', 'involved', 'are', ...]
reader.tagged_words()
reader.sents()
reader.tagged_sents()
reader.paras()
reader.tagged_paras()

# testing the import #
#import sys
import myMath

print myMath.add(4,5)
print myMath.division(4, 2)
print myMath.multiply(10, 5)
print myMath.fibonacci(8)
print myMath.squareroot(48)
Пример #11
0
import sys
import myMath

numbers_list = []

try:
    # Get the input from the parameters..
    input_numbers = str(sys.argv[1])
    numbers_list = [int(s) for s in input_numbers.split(',')]
except IndexError:
    print("Your input is invalid!")
    sys.exit()
except ValueError:
    print("Your input is invalid!")
    sys.exit()

biggest_num = myMath.maximum(numbers_list)
smallest_num = myMath.minimum(numbers_list)
big_small_difference = myMath.subtraction(biggest_num, smallest_num)

summation_of_max_min = myMath.add(biggest_num, smallest_num)
sum_of_all_numbers = myMath.sumTotal(numbers_list)
count_even_numbers = myMath.evenNum(numbers_list)

if smallest_num < 5:
    numbers_list = myMath.clear(numbers_list)

print("The difference is:%d The summation is:%d The summation of all input is:%d The number of even numbers is:%d The values in the list are: %s" % (myMath.subtraction(biggest_num, smallest_num), myMath.add(biggest_num, smallest_num), sum_of_all_numbers, count_even_numbers, numbers_list))
Пример #12
0
import myMath
'''
if ---> module/myMath.py
import module.myMath
'''

print("My first module started")
myMath.add(5, 6)  # module.myMath.add()
myMath.sub(18, 12)
print("My first module ended")

from myMath import add
add(5, 6)

from myMath import add as addition
addition(4, 3)

from myMath import add, mul  #for specific importing

from myMath import *  # for all importing