Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

what is // in python

"""
  '//' is floor division on python which mean
  the result will be rounded down (eg: 3.14 become 3), so
  
  '5 // 2' will be 2
"""
Comment

* in python

>>> fruits = ['lemon', 'pear', 'watermelon', 'tomato']
>>> print(fruits[0], fruits[1], fruits[2], fruits[3])
lemon pear watermelon tomato
>>> print(*fruits)
lemon pear watermelon tomato
Comment

** in python

#** is the exponent symbol in Python, so:
print(2 ** 3)
#output: 8
Comment

// in python

print(3 // 2)
# 1
print(3 / 2)
# 1.5
Comment

** in python

""" depends on the data type too """
def callme(key1, key2):
  print(key1, key2)
    
obj1 ,obj2 = 6, 9
obj3 = {
  "key1": 1,
  "key2": 2
}
callme(**obj3) # easy for calling functions
print(obj1 ** obj2) # Here it is a operator (for calculating obj1 ^ obj2)
Comment

@ in python

# @ is used for matris multiplication
class Mat(list):
    def __matmul__(self, B):
        A = self
        return Mat([[sum(A[i][k]*B[k][j] for k in range(len(B)))
                    for j in range(len(B[0])) ] for i in range(len(A))])

A = Mat([[1,3],[7,5]])
B = Mat([[6,8],[4,2]])

print(A @ B)
Comment

** in python

print(10 * 10)
# 100
print(10 ** 10)
# 10000000000
Comment

** in python


>>> class Adder(object):
        def __init__(self, num=0):
            self.num = num

        def __iadd__(self, other):
            print 'in __iadd__', other
            self.num = self.num + other
            return self.num

>>> a = Adder(2)
>>> a += 3
in __iadd__ 3
>>> a
5

Comment

PREVIOUS NEXT
Code Example
Python :: Python Removing Directory or File 
Python :: sort by multiple keys in object python 
Python :: how to drop a column in python 
Python :: increase a date in python 
Python :: set http response content type django 
Python :: print list in reverse order python 
Python :: pyautogui moveTo overtime 
Python :: minecraft python code 
Python :: random question generator python 
Python :: continual vs continuous 
Python :: correlation analysis of dataframe python 
Python :: hide code in jupyter notebook 
Python :: randomforestregressor in sklearn 
Python :: python dictionary to array 
Python :: # convert dictionary into list of tuples 
Python :: seaborn countplot 
Python :: how can i make a list of leftovers that are str to make them int in python 
Python :: identify total number of iframes with Selenium 
Python :: registration of path in urls.py for your apps for views 
Python :: python tar a directory 
Python :: how to store in parquet format using pandas 
Python :: how to make a venv python 
Python :: iso date convert in python 
Python :: django check if user is admin 
Python :: python recurrent timer 
Python :: numpy euclidean distance 
Python :: if else python 
Python :: python curve fitting 
Python :: rotate point around point python 
Python :: how to add rows to empty dataframe 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =