Convert Positive Number To Negative In Python
Last updated January 31, 2024 by Jarvis Silva
In this article I will show you how to convert positive number to negative using python, to convert positive number to negative we will use the python function called abs() it returns the absolute value of a number it is a built in function so let’s see how to use it.
Python Code To Convert Positive Number To Negative
positive_num = 1
print(-abs(positive_num))
Above is the python code for converting positive number to negative, To run this program you need to have python installed, if you don’t have, then read this: Install and setup python or you can use this online python compiler.
After running the program you will see that it will print a negative number. Want to know how to convert a negative number to positive then read this: Convert negative number to positive in python.
Here are some more python programs you will find helpful:
- Convert Base64 To Pdf In Python.
- Convert Pdf to Base64 In Python.
- Convert GPX to CSV file in python.
- Convert IPYNB file to python file.
- Convert Wav to mp3 format in python.
- Convert Miles to feet in python.
- Convert Hex To RGB In Python.
- Convert RGB To Hex In Python.
- Convert HTML To Docx In Python.
I hope you found what you were looking for from this python tutorial, and if you want more python tutorials like this, do join our Telegram channel to get updated.
Thanks for reading, have a nice day 🙂