Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert negative to positive in python

>>> n = -42
>>> -n       # if you know n is negative
42
>>> abs(n)   # for any n
42
>>> abs(-5.05)
5.05
Comment

python turn positive into negative

a = -abs(a)
Comment

positive and negative number in python

num = float(input("Enter a number: "))
if num > 0:
   print("Positive number")
elif num == 0:
   print("Zero")
else:
   print("Negative number")
Comment

PREVIOUS NEXT
Code Example
Python :: change xticks python 
Python :: reversed function python 
Python :: python pandas series to title case 
Python :: Simple Splash screen in pyqt5 
Python :: if else in 1 line python 
Python :: how to get python list length 
Python :: write list to csv python 
Python :: streamlit headings;streamlit text 
Python :: numpy generate random array 
Python :: python get 2d array output as matrix 
Python :: selenium undetected chromedriver error 
Python :: plotly color specific color 
Python :: download csv file from jupyter notebook 
Python :: python bytes 
Python :: pytest local modules 
Python :: drop row with duplicate value 
Python :: python abc 
Python :: Python Date object to represent a date 
Python :: how to make your own range function in python 
Python :: django create superuser from script 
Python :: how to kill a script if error is hit python 
Python :: np reshape 
Python :: create login system in python 
Python :: python datetime move forward one day 
Python :: how to return a value from a function in python 
Python :: jupyter change cell to text 
Python :: How to get the date from week number in Python? 
Python :: Reverse an string Using Stack in Python 
Python :: python program to print inverted star pattern 
Python :: adding debugger in django code 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =