- Related Setup: https://gist.github.com/hofmannsven/6814278
- Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
- Interactive Beginners Tutorial: http://try.github.io/
- Git Cheatsheet by GitHub: https://services.github.com/on-demand/downloads/github-git-cheat-sheet/
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
#pyramid | |
n=5 | |
for i in range(0,n): | |
s=' '*(n-i) | |
s= s+ '*'*(i*2-1) | |
print(s) |
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
#floyd triangle | |
def floyd(n): | |
count = 1 | |
s = "" | |
for i in range(1,n+2): | |
for j in range(1,i): | |
s = s + " " + str(count) | |
count = count + 1 | |
print(s) | |
s = "" |
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
# a^n --- O(n) | |
def pow(a, n): | |
result = 1.0 | |
for _ in range(n): | |
result = result * a | |
return result | |
print(pow(2, 2)) |
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
def pow(a, n): # a^n --- O(log n) | |
if n == 0: return 1 | |
if n == 1: return a | |
if n % 2 == 1: | |
return a * pow(a, n-1) | |
else: | |
p = pow(a, n/2) | |
return p * p | |
print(pow(2, 2)) |
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 os | |
import sqlite3 | |
import operator | |
from collections import OrderedDict | |
import matplotlib.pyplot as plt | |
import webbrowser as wb | |
def parse(url): | |
try: | |
parsed_url_components = url.split('//') |
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 os | |
import configparser # configparser to read the profiles.ini file in to determine which folder to use | |
mozilla_profile = os.path.join(os.getenv('APPDATA'), r'Mozilla\Firefox') | |
mozilla_profile_ini = os.path.join(mozilla_profile, r'profiles.ini') | |
profile = configparser.ConfigParser() | |
profile.read(mozilla_profile_ini) | |
data_path = os.path.normpath(os.path.join(mozilla_profile, profile.get('Profile0', 'Path'))) | |
# os.path.normpath() is used to ensure backslashes are used. |
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
a = int(input()) # direct input with casting | |
a,b=input().split() # input a and b | |
a,b=map(int,input().split()) # input a and b with casting |
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
# recursive abacus | |
def inc(x,n=0): return inc(x^(1<<n),inc(0,n)) if x&(1<<n) else x|x^(1<<n) | |
# there are 10 type of coders ... | |
lambda i: i++ (lambda j: j()**j())(type(i)) #halike | |
# dyslexia | |
lambda i: (sum(range(x))*2)/x # decrement #halike | |
# it's all about the context |
Getting started:
Related tutorials:
OlderNewer