Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

_ in python

"""Use of _ as a variable
It is to indicate throwaway variables, 
...i.e. variables that are not reused anywhere else (as they are...
        ...not logically important) but for syntax reasons you have to put

This saves space for variables that are actually reused...
...and provides a good mental model for essential and unessential parts...
...of your code

Of course, take this as a guideline. 
There are instances where naming those variables are better for readability...
...especially in group projects

Check out the source for more info!
"""

lst1 = [_ for _ in range(10)]
print(lst1)
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Comment

_ in python

print(7//3) # Returns the Quotient
print(7/3)  # Returns Division
_ #is used in the interactive interpreter to store the result of the last evaluation
_/2 # Valid in operation
Comment

_ in python

>>> a = 10
>>> b = 10
>>> _
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> a+b
20
>>> _
20
>>> _ * 2
40
>>> _
40
>>> _ / 2
20
Comment

PREVIOUS NEXT
Code Example
Python :: how to do more than or less than as a condition in pythonb 
Python :: two pointer function in python 
Python :: pivot table pandas 
Python :: python write float with 2 decimals 
Python :: datetime conversion 
Python :: .squeeze function in numpy 
Python :: NumPy invert Syntax 
Python :: check for null values in rows pyspark 
Python :: child class in python 
Python :: python random numbers 
Python :: geodataframe get crs 
Python :: combine 3 jupyter cells together 
Python :: python find length of list 
Python :: frequency 
Python :: google youtuve api python 
Python :: Python RegEx Subn – re.subn() Syntax 
Python :: print file in python 
Python :: if or python 
Python :: django-multivaluedictkeyerror-error 
Python :: matplotlib units of scatter size 
Python :: convert images to jpeg 
Python :: bresenham circle drawing algorithm 
Python :: how to make python faster than c++ 
Python :: python list pop equivalent 
Python :: python programming language 
Python :: flask page 
Python :: drop variable pandas 
Python :: when converting from dataframe to list delete nan values 
Python :: what is an indefinite loop 
Python :: download pdf file python 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =