Ejemplo n.º 1
0
def mainfn():
    print("hola", suma(4, 5, 6, 7))
    print(calcula(2, 4, 6))
    print(nombres)
    print(q)

    print(__name__)
Ejemplo n.º 2
0
def apartamentos():
    if request.method == 'POST':
        n1 = float(request.form['n1'])
        n2 = float(request.form['n2'])
        sum = suma(n1, n2)
        rest = resta(n1, n2)
        raizz = raiz(n1, n2)
        return render_template('apartamentos.html',
                               n1=n1,
                               n2=n2,
                               sum=sum,
                               rest=rest,
                               raizz=raizz)

    return render_template('apartamentos.html')
def test_suma():
    assert operaciones.suma(2,3) ==5
    assert operaciones.suma(2)==2
def test_suma_string():
    resultado = operaciones.suma('Hola ', 'Mundo')
    assert resultado == 'Hola Mundo'
    assert type(resultado) is str
    assert len(resultado) > 0
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
import operaciones as math

print "Mi aplicación de Calculadora"
print "La suma de 5+2 es:{0}".format(math.suma(5, 2))
print "La resta de 9-3 es: {res}".format(res=math.resta(9, 3))
#print math.multiplicacion(2,3)
print math.multiplicacion(n2=3, n1=2, n0=0)
Ejemplo n.º 6
0
#coding: utf-8

import operaciones
import sys

n = len(sys.argv)
if n != 3 : 
	print "Args: numero1 numero2"
	sys.exit(1)

try: 
	n1 = float ( sys.argv[1] )
except ValueError:
	print "El primer argumento no es un número"
	sys.exit(2)

try: 
	n2 = float ( sys.argv[2] )
except ValueError:
	print "El segundo argumento no es un número"
	sys.exit(2)

r1 = operaciones.suma (n1,n2)
r2 = operaciones.resta(n1,n2)
r3 = operaciones.multiplicacion(n1,n2)

print r1,r2,r3
Ejemplo n.º 7
0
import operaciones

print(str(operaciones.suma(5, 8)))
print(str(operaciones.resta(12, 5)))
print(operaciones.suma.__doc__)
def test_suma_string():
    resultado = operaciones.suma('Hola ', 'Mundo')
    assert resultado == 'Hola Mundo'
Ejemplo n.º 9
0
# envía raiz todos los datos a todos los procesadores
A = comm.bcast(A, root=0)
B = comm.bcast(B, root=0)

A11 = [A[0][0:2], A[1][0:2]]
A12 = [A[0][2:4], A[1][2:4]]
A21 = [A[2][0:2], A[3][0:2]]
A22 = [A[2][2:4], A[3][2:4]]

B11 = [B[0][0:2], B[1][0:2]]
B12 = [B[0][2:4], B[1][2:4]]
B21 = [B[2][0:2], B[3][0:2]]
B22 = [B[2][2:4], B[3][2:4]]

if rank == 0:
    P1 = mul(suma(A11, A22), suma(B11, B22))
    P2 = mul(suma(A21, A22), B11)
    P6 = comm.recv(source=1, tag=11)
    P3 = mul(A11, resta(B12, B22))
    C22 = suma(resta(suma(P1, P3), P2), P6)
    P5 = comm.recv(source=1, tag=22)
    comm.send(P2, dest=1, tag=33)
    C12 = suma(P3, P5)
    comm.send(P1, dest=1, tag=44)
    C21 = comm.recv(tag=100)
    C11 = comm.recv(tag=110)

elif rank == 1:
    P4 = mul(A22, resta(B21, B11))
    P6 = mul(resta(A21, A11), suma(B11, B12))
    comm.send(P6, dest=0, tag=11)
Ejemplo n.º 10
0
    cliente.send(clave)

    if (mensaje_cliente == 'lina' and clave == '1234'):
        print "CALCULAD0RA"

    else:
        print 'No puede Acceder'
        break

    lista = ['1.suma', '2.Resta', '3.Multiplicacion', '4.Division', '5.salir']

    for i in lista:
        print i

# opcion=raw_input('Ingrese la operacion a Realizar')
#cliente.send(opcion)

    import operaciones

    operaciones.suma()
    operaciones.resta()
    operaciones.producto()
    operaciones.division()

    if mensaje_cliente == "salir":

        break

print "vuelva cuando quiera"
cliente.close()
Ejemplo n.º 11
0
import operaciones
import cuadrado
print(operaciones.suma(10, 5))
print(cuadrado.cuadrado(5))
Ejemplo n.º 12
0
def test_suma(num1, num2, resultado):
    assert operaciones.suma(num1, num2)==resultado 
Ejemplo n.º 13
0
def main():
    
    sg.theme('LightGreen')
    w,h = sg.window.get_screen_size()
    
    menu_sec = ['Abrir',['Abrir A','Abrir B','Guardar',],]

    contenedor1 = [[sg.Image(filename='', key='-IMAGE1-',right_click_menu=menu_sec)]]
    contenedor2 = [[sg.Image(filename='', key='-IMAGE2-',right_click_menu=menu_sec)]]
    contenedor3 = [[sg.Image(filename='', key='-IMAGE3-',right_click_menu=menu_sec)]]

    layout = [
        [sg.Menu(menu_def, tearoff=False, pad=(200,1))],
        [sg.Text('Operaciones',size=(60,1), key='-nombre_archivo-',)],
        [sg.Column(contenedor1, size(w/3, h-100), scrollable=True),
        sg.Column(contenedor2, size(w/3, h-100), scrollable=True, element_justification='center'),
        sg.Column(contenedor3, size(w/3, h-100), scrollable=True, element_justification='center')],
        [sg.Button('Abrir A',size=(15,2), font='Consolas 11'),
        sg.Button('Abrir B',size=(15,2), font='Consolas 11'),
        sg.Button('Guardar', size=(15,2), font='Consolas 11'),
        sg.Button('Salir', size=(15,2), font='Consolas 11')]
    ]

    imagen1 = np.ones((1024,600))
    imagen2 = np.ones((1024,600))
    imagen3 = np.ones((1024,600))

    window = sg.window('Calculadora de Imagenes', layout, location=(0,0))

    while True:
        event, values = window.read(timeout=50)

        #Abrir Imagen A
        if event == 'Abrir A':
            filename = sg.poput_get_file('Abrir archivo (PNG, JPG)', file_types=(("Archivos PNG","*.png"),), no_window=True)
            imagen1 = cv2.imread(filename)
            window['-nombre_archivo-'].update(filename)
        
        #Imagen B
        if event == 'Abrir B':
            filename = sg.poput_get_file('Abrir archivo (PNG, JPG)', file_types=(("Archivos PNG","*.png"),), no_window=True)
            if len(filename):
                imagen2 = cv2.imread(filename)
                window['-nombre_archivo-'].update(filename)

        #Salir
        if event == 'Salir' or event == sg.WIN_CLOSED:
            break;

        #Guardar
        if event == 'Guardar':
            filename = sg.poput_get_file('Guardar imagen (PNG)', save_as=True, file_types=(("Archivos PNG","*.png"),), no_window=True)
            try:
                cv2.imwrite(filename,imagen3)
                window['-nombre_archivo-'].update(filename)
            except:
                sg.poput_error("No se guardó el archivo")
        
        #Suma
        if event == 'Suma':
            imagen = operaciones.suma(imagen1, imagen2)

        #Resta
        if event == 'Resta':
            imagen = operaciones.resta(imagen1, imagen2)

        #Multiplicación
        if event == 'Multiplicacion':
            imagen = operaciones.multiplicacion(imagen1, imagen2)

        #XOR
        if event == 'XOR':
            imagen = operaciones.XOR(imagen1, imagen2)

        #NAND
        if event == 'NAND':
            imagen = operaciones.NAND(imagen1, imagen2)


        imgbytes1 = cv2.imencode('.png',imagen1)[1].tobytes()
        imgbytes2 = cv2.imencode('.png',imagen2)[1].tobytes()
        imgbytes3 = cv2.imencode('.png',imagen3)[1].tobytes()

        window['-IMAGE1-'].update(data=imgbytes)
        window['-IMAGE2-'].update(data=imgbytes)
        window['-IMAGE3-'].update(data=imgbytes)
    
    window.close()
Ejemplo n.º 14
0
from operaciones import producto, suma

#print("4*6=", operaciones.producto(4, 6))
print("4*6=", producto(4, 6))
print("5+3=", suma(5, 3))
Ejemplo n.º 15
0
import operaciones

num1=operaciones.cargar()
num2=operaciones.cargar()
suma=operaciones.suma(num1,num2)
print("El primer valor es: ",num1)
print("El segundo valor es: ",num2)
print("La suma de los valores es: ",suma)

Ejemplo n.º 16
0
# Problema 10
print('Problema 10')

import operaciones
resultado = operaciones.suma(56, 89)
print(resultado)

resultado = operaciones.resta(56, 89)
print(resultado)

resultado = operaciones.multiplicacion(56, 89)
print(resultado)

resultado = operaciones.division(56, 0)
print(resultado)
Ejemplo n.º 17
0
import operaciones

a = 2.1
b = 3.2

print(operaciones.suma(a, b))
print(operaciones.resta(a, b))
Ejemplo n.º 18
0
def calcula(a, b, c):
    return suma(a, b) * c
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 12 16:34:48 2016

@author: JavierTejedorAguilera
"""

import os
import operaciones as op
op.suma(1,2)

def devuelve_doble():
    while True:
        try:
            x=int(input("Introduce un numero:"))
            return 2*x
        except:
            print("Error. El valor introducido no es un número")

devuelve_doble()

def divide():
    while True:
        try:
            x=int(input("Dividendo:"))
            y=int(input("Divisor:"))
            return x/y
        except ValueError:
            print("Valor no admitido, debe ser un número")
        except ZeroDivisionError:
            print("División por 0")
def test_suma_float():
    assert operaciones.suma(3.1, 3.1) == 6.2
    assert operaciones.suma(12.5, 1.2) == 13.7