Пример #1
0
def main() -> None:
    """
    See README.md for exercises.
    :return: None
    """

    print(f"Subtracting 2 from 4")
    c = subtract(4, 2)
    print(f"Result: {c}")

    print(f"Subtracting 2 from 4.4")
    c = subtract(4.4, 2)
    print(f"Result: {c}")

    print(f"Subtracting 2 from 4.6")
    c = subtract(4.6, 2)
    print(f"Result: {c}")

    print(f"Subtracting 2.2 from 4")
    c = subtract(4, 2.2)
    print(f"Result: {c}")

    print(f"Subtracting 1.9 from 4")
    c = subtract(4, 1.9)
    print(f"Result: {c}")
Пример #2
0
def main(a, b) -> None:
    """
    See README.md for exercises.
    :return: None
    """

    print(f"Subtracting {b} from {a}")
    c = subtract(a, b)
    print(f"Result: {c}")
Пример #3
0
from cyt_module import subtract
from add_module import add

sol = subtract(4.5, 2)
print(sol)

print(add(1000, 5000))
Пример #4
0
from cyt_module import subtract
print(subtract(1, 4))
print(subtract(1.1, 4))
Пример #5
0
from cyt_module import subtract

a = subtract(4.5, 2)
print(a)
Пример #6
0
from cyt_module import subtract

print(subtract(4.5, 2))
Пример #7
0
from cyt_module import subtract

subtract(4.5, 2)
Пример #8
0
from cyt_module import subtract
"""
As the C-extension implements the fully dynamic Python code (just using the Python C-API), transforming the pure Python 
module into C-extension gives normally only very modest speed-ups. However, as we will discuss in the following steps, 
by adding Cython language extensions into the code (.pyx?, so it is no longer valid Python code) it is possible to achieve much 
more significant performance improvements.

Uses the cyt_module.cp37-win_amd64.pyd C-extension.
"""

z = subtract(5, 2)
print(z)
Пример #9
0
from cyt_module import subtract

a = subtract(4.5, 1.5)
print(a)
Пример #10
0
def main():

	print(subtract(4.5, 2))
	x = np.array((1,2,3,4,5,6,7,8,9,10))
	y = np.array((4.2, 5.2, 5.7, 4, 5.3, 5, 6.32, 5, 6.6, 10))
	print(subtract(x, y))
Пример #11
0
from cyt_module import subtract
'''
1. internal var result declared as int: 
for float intputs, subtraction is computed and then rounded down to the nearest integer

2. func arguments declared as int
for float inputs, arguments are first rounded down to nearest integer and then subtraction is computed

3. error: cannot assign type 'float' to 'int'

 '''

print(subtract(4, 3))
print(subtract(5.0, 2.4))