Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get random number positive or negative python

import random
return 1 if random.random() < 0.5 else -1
Comment

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

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 :: what are arrays in python 
Python :: if else statement python one line 
Python :: how to debug python code in visual studio code 
Python :: python virtual env 
Python :: hash in python 
Python :: matplotlib subplots share x axis 
Python :: char in python 
Python :: def rectangles 
Python :: calculator python tutorial 
Python :: shape in python 
Python :: how to find gcd of two numbers in python 
Python :: re python 
Python :: python elif syntax 
Python :: python squared 
Python :: min max code in python 
Python :: pandas add prefix to column names 
Python :: indent python 
Python :: list operations in python 
Python :: get category discord.py 
Python :: python os check if file with extension exists 
Python :: 2)Write a function that checks whether a number is in a given range (inclusive of high and low) python 
Python :: django connexion session time 
Python :: creating dynamic variable in python 
Python :: how to create a variable that represents any integer in python 
Python :: printing first n prime numbers 
Python :: compare list and dataframe in pandas 
Python :: analyse des fleurs du mal la vision du baudelaire 
Python :: Write a Python program to accept two strings as input and check if they are identical copy of each other or if the second string is a substring of the first string. 
Python :: file = Root() path = file.fileDialog() print("PATH = ", path) 
Python :: access dynamicall to name attribute python 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =