Basic - 1

1. Import

import numpy as np
from six.moves import cPickle as pickle

2. Multi-line statement

a = 1 + 2 + 3 + \
    4 + 5 + 6 + \
    7 + 8 + 9

a = 1; b = 2; c = 3

a = (1 + 2 + 3 +
    4 + 5 + 6 +
    7 + 8 + 9)

3. __doc__

def double(num):
    """Function to double the value"""
    return 2*num

>>> print(double.__doc__)
Function to double the value

4. list, tuple, set, dictionary

  • list = ordered collections

  • tuple = immutable list

  • set = unordered, unique collections

  • dictionary = key-value pair

5. string format

Last updated

Was this helpful?