CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of python
C++
from math import *
 
def sumOfDigit(n):
    if n<10: return n
    sum = 0
    if n >0:
        sum += n%10
        n /= 10
    return sum
by Pella86   December 23, 2011 @ 5:10pm
141 Views
no comments
 
# Write the pseudocode for a program where the player and the computer trade
# places in the number guessing game. That is, the player picks a random number between
# 1 and 10 that the computer has to guess. Before you start, think about how you guess.
 
welcome player to the game and explain it
player picks a random number between 1 and 100
ask the computer for a guess
set compguessCount to 1
    while the computer's guess does not equal player's number
          if the guess > player number
by Azul-P   November 14, 2010 @ 4:01pm
440 Views
no comments
 
import random
lifechance = .1 ## 10 % chance for life in square
board = []
for x in range (50):
    # '*' == life, '' == dead
    board.append(['*' if random.random()<lifechance else ''
                  for notcare in range(50)])
# make strings for lines replacing '' values (which are considered False) with ' '
print '\n'.join(''.join(life if life else ' '
                        for life in row)
by tonyjv   August 30, 2010 @ 11:27pm
149 Views
no comments
 
C#
if (componentID == 0 && mgr != null) {
    OLECRINFO[] crinfo = new OLECRINFO[1];
    crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
    crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                  (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
    crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                  (uint)_OLECADVF.olecadvfRedrawOff |
                                  (uint)_OLECADVF.olecadvfWarningsOff;
    crinfo[0].uIdleTimeInterval = 1000;
    int hr = mgr.FRegisterComponent(this, crinfo, out componentID);
by mikecvelide   October 08, 2009 @ 10:59am
235 Views
no comments
 
class Parent:
    def test(self):
        print "parent"
 
class Child(Parent):
    def t(self):
        self.test()
 
if __name__ == '__main__':
    obj = Child()
by yuyu1984   September 02, 2009 @ 6:55pm
Tags: python
170 Views
no comments
 
#url:http://www.javaeye.com/topic/423131
#save binary into sqlite
 
from __future__ import with_statement
import sqlite3
 
db = sqlite3.connect('test.db')
cur = db.cursor()
 
cur.execute("CREATE TABLE if not exists t (b BLOB);")
by yuyu1984   July 21, 2009 @ 11:13pm
230 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate