To divide two numbers in Python, you can use the /
operator. Here's an example:
main.py54 chars5 lines
Output:
main.py4 chars2 lines
In this example, num1
and num2
are the two numbers we want to divide. The /
operator divides num1
by num2
and returns the result, which we store in the variable result
. Finally, we print result
to the console.
gistlibby LogSnag