Format:
Recent snippets matching tags of python
from math import *
def sumOfDigit(n):
if n<10: return n
sum = 0
if n >0:
sum += n%10
n /= 10
return sum
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
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)
149 Views
no comments
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);
235 Views
no comments
class Parent: def test(self): print "parent" class Child(Parent): def t(self): self.test() if __name__ == '__main__': obj = Child()
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);")
230 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
