This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@Author: Sujayyendhiren Ramarao Srinivasamurthi | |
@Description: Fun with args and kwargs | |
""" | |
def function1 ( *args, ** kwargs): | |
print "" | |
print args | |
print kwargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@Author: Sujayyendhiren Ramarao srinivasamurthi | |
@Description: Scalar product Reference data and code used from | |
http://www.python-course.eu/matrix_arithmetic.php | |
""" | |
import numpy as np | |
#Dot product | |
x = np.array( [1, 2, 3]) | |
y = np.array( [-7, 8, 9]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@Author: Sujayyendhiren Ramarao Srinivasamurthi | |
@Description: Selection sort | |
""" | |
def selection_sort( arr2sort ): | |
for idx in range(len(arr2sort)): | |
min = idx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@Author: Sujayyendhiren Ramarao Srinivasamurthi | |
@Description: Bubble sort implementation | |
""" | |
def bubble_sor( arr2Sort ): | |
for x in range(len(arr2Sort)): | |
sortCnt = 0 | |
for idx in range( len(arr2Sort) - x - 1): | |
if (arr2Sort[idx] > arr2Sort[idx+1]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@Author: Sujayyendhiren | |
@Description: Depth first search | |
""" | |
def backtrack( visitedParent, start, end ): | |
result = [] | |
node = end | |
result.insert(0,end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@Author: Sujayyendhiren | |
@Description: Sorted array for binary tree construction | |
""" | |
class Node: | |
def __init__(self, value): | |
self.value = value | |
self.left = None | |
self.right = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--------------------------------------------------------------------------------# | |
# Author: Sujayyendhiren Ramarao Srinivasamurthi # | |
# Email: sujayy1983@gmail.com # | |
# Book for wxPython: 'wxPython in Action' Noel Rappin and Robin Dunn # | |
#--------------------------------------------------------------------------------# | |
import wx | |
import random | |
import TorsHammer | |
import Goldeneye |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--------------------------------------------------------------------------------# | |
# Author: Sujayyendhiren Ramarao Srinivasamurthi # | |
# Email: sujayy1983@gmail.com # | |
# Book for wxPython: 'wxPython in Action' Noel Rappin and Robin Dunn # | |
#--------------------------------------------------------------------------------# | |
import wx | |
import random | |
import os | |
import Description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
""" | |
http://www.diveinto.org/python3/regular-expressions.html | |
""" | |
""" | |
Example 1: | |
Important points: Use raw string 'r' and \b tells the word boundary | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@Author: Sujayyendhiren Ramarao Srinivasamurthi | |
@Description: An Example of magic function __call__() | |
""" | |
class testCls: | |
def __init__(self): | |
self.a = 5 | |
def __call__(self, *args, **kwargs): |