You haven't called the function!

def test(foundN):
    if foundN%2 == 0:
        print "The number ", foundN, "is ok."
    else:
        print "Try another number. "

foundN = input("Enter number: ")
test(foundN)
Answer from Ry- on Stack Overflow
Discussions

python - Find the division remainder of a number - Stack Overflow
Note that the modulo operator always ... would expect when talking about the remainder: -10 % 3 == 2. However a/b*b + a%b == a still holds true, since python always rounds towards -Infinity, unlike some other languages, which round towards 0 but would return -1.... More on stackoverflow.com
🌐 stackoverflow.com
Please help me with this code.
Well, first of all, you need to perform the test to see if the user has input 0 for the divisor (the number to divide by) before you attempt the division. Otherwise, you'll hit an error. Fortunately, you can do this by simply rearranging your code. Also, you're defining your dividend and divisor within your function; you don't need to send them as parameters to the function. This, for example, ought to work (note the lack of a def header): num_1 = int(input("Please enter the number to divide by: ")) num_2 = int(input("Please enter the number to divide: ")) if num_1 == 0: print('ERROR! Division by zero is undefined.') elif num_2 == 0: print('Zero divided by anything is zero.') else: remainder = num_2 % num_1 if remainder: print(f"{num_2} is not divisible by {num_1}, there is a remainder of {remainder}.") else: print(f"{num_2} is divisible by {num_1}") NOTE: Edited to address spelling error. More on reddit.com
🌐 r/learnpython
19
7
June 20, 2023
How does 'if (number % 2 == 0)' work in this example?
✨ Earn college credits in Cybersecurity, JS, HTML, CSS and Python ... def even_odd(number): if (number % 2 == 0): # <------ how does this work, what happens here? Check if the remainder of number 2 becomes zero? More on teamtreehouse.com
🌐 teamtreehouse.com
2
March 29, 2017
How to divide without remainders on Python - Stack Overflow
In this code i am trying to randomly create division questions for primary school age (10 years) so I don't want any remainders when it dividies. This is the code I have, but I am unsure on how to ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Python Central
pythoncentral.io › using-python-to-check-for-odd-or-even-numbers
Using Python to Check for Even Numbers | Python Central
February 23, 2017 - To do this, you need to use the ... the remainder of the first number divided by the second number. If the second number goes into the first evenly, then there is no remainder and the calculated answer is 0......
🌐
GeeksforGeeks
geeksforgeeks.org › python › what-is-a-modulo-operator-in-python
Modulo operator (%) in Python - GeeksforGeeks
December 20, 2025 - One of the most common uses of the modulo operator is to check whether a number is even or odd. A number is even if it leaves a remainder of 0 when divided by 2.
🌐
Real Python
realpython.com › python-modulo-operator
Python Modulo Operator (%): How to Use Mod in Python – Real Python
April 1, 2023 - That said, you should avoid comparing the result of a modulo operation with 1 as not all modulo operations in Python will return the same remainder. ... In the second example, the remainder takes the sign of the negative divisor and returns -1. In this case, the Boolean check 3 % -2 == 1 would return False. However, if you compare the modulo operation with 0, then it doesn’t matter which operand is negative.
🌐
W3Schools
w3schools.com › python › ref_math_remainder.asp
Python math.remainder() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... # Import math Library import math # Return the remainder of x/y print (math.remainder(9, 2)) print (math.remainder(9, 3)) print (math.remainder(18, 4)) Try it Yourself »
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › python modulo operator
Python Modulo Operator: Examples, Uses and Importances
June 6, 2024 - Explanation: In the above example, x = 5 , y =2, so 5 % 2 , 2 goes into 5 twice, yielding 4, so the remainder is 5 – 4 = 1. To obtain the remainder in Python, you can use the numpy.remainder() function found in the numpy package.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Find elsewhere
🌐
Career Karma
careerkarma.com › blog › python › how to use the python modulo operator
How to Use the Python Modulo Operator | Career Karma
December 1, 2023 - The modulo operator is placed between two numbers. In the above example, we assign the result of our sum to the Python variable “example”. If there is no remainder after dividing the first number by the second, the modulo operator will return 0.
🌐
Linuxize
linuxize.com › home › python › python modulo operator
Python Modulo Operator | Linuxize
June 16, 2020 - For example, 5 divided by 3 equals 1, with a remainder of 2, and 8 divided by 4 equals 2, with a remainder of 0. In Python, the modulo operator is represented by the percent sign (%). The syntax is as follows: ... When formatting strings, the % character represents the interpolation operator. One of the common use cases of the modulo operator is to check whether a number is odd or even.
🌐
Reddit
reddit.com › r/learnpython › please help me with this code.
r/learnpython on Reddit: Please help me with this code.
June 20, 2023 -

I have been trying to make a code for divisions that outputs if your 2 numbers are divisible or if they have a remainder. I need to add an error system to make it output "ERROR" if the user inputs 0 but whenever i input zero for the 1 number the code malfunctions, this is the code: i use python in visual studio code.

def division (num_1, num_2):
    num_1 = int(input("Please enter the number to divide by: "))
    num_2 = int(input("Please enter the number to divide: "))

    division = num_2 / num_1
    remainder = num_2 % num_1
    if num_2 == (0): 
        print("ERROR!")
    elif num_1 == (0):
        print("ERROR!")
    elif remainder:
        print(f"{num_2} is not divisable by {num_1}, there is a remainder of {remainder}.")
    else:
        print(f"{num_2} is divisable by {num_1}")
Top answer
1 of 4
7
Well, first of all, you need to perform the test to see if the user has input 0 for the divisor (the number to divide by) before you attempt the division. Otherwise, you'll hit an error. Fortunately, you can do this by simply rearranging your code. Also, you're defining your dividend and divisor within your function; you don't need to send them as parameters to the function. This, for example, ought to work (note the lack of a def header): num_1 = int(input("Please enter the number to divide by: ")) num_2 = int(input("Please enter the number to divide: ")) if num_1 == 0: print('ERROR! Division by zero is undefined.') elif num_2 == 0: print('Zero divided by anything is zero.') else: remainder = num_2 % num_1 if remainder: print(f"{num_2} is not divisible by {num_1}, there is a remainder of {remainder}.") else: print(f"{num_2} is divisible by {num_1}") NOTE: Edited to address spelling error.
2 of 4
2
There are multiple problems with your code: def division (num_1, num_2): num_1 = int(input("Please enter the number to divide by: ")) num_2 = int(input("Please enter the number to divide: ")) Your code must be called with two arguments, (num_1, num_2), but then you immediately discard those values and replace them with user input. 2. if num_2 == (0): Should be: if num_2 == 0: Similarly for: elif num_1 == (0): 3. It would be better to use divmod() Edit: If you really need to use division at all. (See the other comments below). 4. You need to either: Check for zero before attempting to divide (division by zero is an error) Use try / except to catch the ZeroDivisionError exception.
🌐
DataCamp
datacamp.com › tutorial › modulo-operator-python
Modulo Operator in Python: Understanding Key Concepts | DataCamp
March 12, 2025 - This ensures that the result is always between 0 and b (exclusive) when b is positive, or between b and 0 (exclusive) when b is negative. The modulo operator (%) in Python calculates the remainder of a division operation.
🌐
Python
mail.python.org › pipermail › tutor › 2007-May › 054282.html
[Tutor] How to test for a remainder from division
May 14, 2007 - > Matt > Matt: I'm not sure about your pseudocode, but have you tried to accomplish this with the modulus operator? It provides the remainder of integer division (i.e. a remainder of 0 indicates a perfect divisor.) so you could do: if year % 4 or year % 100 or year % 400: #then it's divisible ...
🌐
LabEx
labex.io › tutorials › python-how-to-check-if-a-number-is-divisible-by-another-in-python-559547
How to Check If a Number Is Divisible by Another in Python | LabEx
In Python, we can check for divisibility using the modulo operator (%). The modulo operator returns the remainder of a division. If the remainder is 0, it means the number is divisible.
🌐
CodeRivers
coderivers.org › blog › remainder-in-python
Understanding the Remainder in Python: Concepts, Usage, and Best Practices - CodeRivers
February 4, 2025 - Here, 7.5 divided by 2.5 gives a quotient of 3 and a remainder of 0. So, the output will be 0.0. One of the most common uses of the remainder operation is to check if a number is divisible by another number.
🌐
Mimo
mimo.org › glossary › python › modulo-operator
Mimo: The coding platform you need to learn Web Development, Python, and more.
That’s where string formatting helps, especially when printing remainders in messages: ... Python's result keeps the sign of the divisor. Always test with negative inputs to avoid logical bugs. The modulo operator is highly optimized and runs in constant time (O(1)) for standard numeric types. It has negligible overhead, making it ideal for tight loops, real-time computations, and systems that require fast condition checks.