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
'''Physics problem Solver | |
Finds Distance, Time or Speed according to input | |
''' | |
import wx | |
class MyFrame(wx.Frame): | |
def __init__(self, parent, id, title): |
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
grid= [['','',''], | |
['','',''], | |
['','','']] | |
def x(y,x): | |
'''Player X's turn | |
''' | |
if not grid[y][x]: | |
grid[y][x]='x' | |
if check_status(grid)!=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
#all the imports | |
import sqlite3 | |
from flask import Flask, request,session, g, redirect, url_for, abort, render_template, flash | |
from contextlib import closing | |
#configuration | |
DATABASE= 'tmp/flaskr.db' | |
DEBUG= True | |
SECRET_KEY= 'development key' ##more difficult | |
USERNAME= 'admin' |
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 urllib2 | |
from BeautifulSoup import BeautifulSoup | |
HN_url = "http://news.ycombinator.com" | |
def get_page(): | |
page_html = urllib2.urlopen(HN_url) | |
return page_html | |
def get_stories(content): |
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 naiveprime(n): | |
primelist = [] | |
for num in range(int(n+1)): | |
prime= True | |
for i in range(2,int(num)): | |
if (num%i)==0: | |
prime=False | |
break | |
if prime==True: primelist.append(num) |
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 sieve(n): | |
"""Finds all prime numbers upto n | |
""" | |
primelist = [] | |
intlist = list(range(int(n+1))) | |
fin = int(n**0.5) | |
for i in range(2,fin+1): | |
intlist[2*i::i] = [None] * len(intlist[2*i::i]) | |
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
unsorted_list=[45,99,1,-22,7,3,294,10,36] | |
def insertion_sort(unsorted): | |
for i in range(1,len(unsorted)): | |
for j in range(i): | |
if unsorted[i]<unsorted[j]: | |
unsorted[i], unsorted[j] = unsorted[j], unsorted[i] | |
print unsorted | |
return unsorted |
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 quicksort(list): | |
if len(list) <= 1: return list | |
pivot = list[0] | |
great = [] | |
less = [] | |
for item in list[1:]: | |
if item>=pivot: | |
great.append(item) | |
elif item<pivot: |
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
function quicksort(a) { | |
if (a.length == 0) return []; | |
var great = [], less = [], pivot = a[0]; | |
for (i=1; i<a.length; i++){ | |
if (a[i]>pivot) | |
great.push(a[i]); | |
else { |
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
from __future__ import division | |
def trapezium(f, n, a, b): | |
''' | |
f- function [f(x)] | |
n- number of trapeziums | |
a- lower limit | |
b- upper limit | |
Returns definite integral of f(x) from range a to b | |
''' |
OlderNewer