Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pass integer by reference in Python

# when you want to pass immutable data types as references in Python, return multiple instead
def RectToPolar(x, y):
    r = (x ** 2 + y ** 2) ** 0.5
    theta = math.atan2(y, x)
    return r, theta # return 2 things at once

r, theta = RectToPolar(3, 4) # assign 2 things at once
Comment

PREVIOUS NEXT
Code Example
Python :: hh:mm to mins in python 
Python :: getting python class from string 
Python :: python string assignment by index 
Python :: hill cipher 
Python :: python largest common divisor 
Python :: onehotencoder = OneHotEncoder(categorical_features = [1]) X = onehotencoder.fit_transform(X).toarray() X = X[:, 1:] 
Python :: python code 
Python :: clear all value in set on python 
Python :: how to import something in python 
Python :: python open zip file 
Python :: python compare dates 
Python :: pandas include nan in value_counts 
Python :: python get time executed by function 
Python :: open csv in coalb 
Python :: 4D Array To DF 
Python :: Fastest way to Convert Integers to Strings in Pandas DataFrame 
Python :: python cassandra 
Python :: generate a list with random length and with random numbers python 
Python :: conditional and in python 
Python :: open multiple urls 
Python :: python cursor placement 
Python :: what is modulus in python 
Python :: string format method python 
Python :: run python in c ++ 
Python :: django permissions 
Python :: create array numpy 
Python :: seaborn countplot hue stacked 
Python :: python dataframe show row 
Python :: pandas replace multiple values in column 
Python :: invalid syntax python else 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =