function does not return python value

0

This is a simple program that returns when a number is even or odd. What I want is to practice a function within another function, that's why this simple program.

Each of the functions have their respective arguments. The module "returnIfParOrImpar" goes inside the module "message_ReturnIfParOrImpar" and at the same time the latter goes into a main program (in which I will not use the module "returnIfParOrImpar" directly but that will be used by the module "message_ReturnIfParOrImpar.")

Module message_ReturnIfParOrImpar:

import retornoIfParOrImpar as nup
n=2
def retorno(n):
    if nup.par_impar(n) == 0:
        print("El numero es par")
    else:
        print ("El numero es impar")

Return moduleIfParOrImpar :

def par_impar(a):
    residuo = a%2
    return residuo

My question is that I am testing the module "messageReturnIfParOrImpar" and although it does not mark an error in the IDE, it does not print on the screen. Could this be declaring the arguments of the functions wrong?

Greetings to all.

    
asked by NIN 24.08.2018 в 22:38
source

1 answer

0

I'm testing your code and it works well for me, you should verify that when you do this

import numPar as nup

You are importing a file, and that file must be strictly named numPar.py

Tests

Try this

def retorno(n):
    x = nup.par_impar(n)
    if x == 0:
        print("El numero es par")
    else:
        print ("El numero es impar")
    
answered by 24.08.2018 / 22:53
source