Skip to content

Instantly share code, notes, and snippets.

@Telltak
Telltak / ex13ec.py
Created November 7, 2010 19:45
My 'extra credit' answer for lpthw exercise 13 part 3
from sys import argv
script, first, second, third = argv
print "this script , called %s, is going to ask you the questions %s, %s, %s" % ( script, first, second, third)
first_answer = raw_input(first)
second_answer = raw_input(second)
third_answer = raw_input(third)
print "for question %r, you answered %s" % ( first, first_answer)
@Telltak
Telltak / ex17.py
Created November 11, 2010 17:30
my answer to lpthw exercise 17 extra credit 3.
from sys import argv
open(argv[2], 'w').write(open(argv[1]).read())
@Telltak
Telltak / logic.py
Created November 18, 2010 19:47
Based on exercise 27 of lpthw, gives a statement and user must answer true or false.
import random
statement_answer_pairs = {'not False ':'true', 'not true ':'false',
'True or False ':'true', 'True or True ':'true',
'False or True ':'true', 'False or False ':'false',
'True and False ':'false', 'True and True ':'true',
'False and True ':'false', 'False and False ':'false',
'not (True or False) ':'false', 'not (True or True) ':'false',
'not (False or True) ':'false', 'not (False or False) ':'true',
'not (True and False) ':'true', 'not (True and True) ':'false',
'not (False and True) ':'true', 'not (False and False) ':'true',
@Telltak
Telltak / prime.py
Created December 6, 2010 08:31
A python script to generate and check prime numbers. Usage for 100 runs(generates 5017 primes): python prime.py 100
from sys import argv
from fractions import gcd
primes = [2, 3]
def isprime(p):
if p == 2: return True
if p % 2==0: return False
max = p**0.5+1
i=3
while i <= max:
if p%i==0: return False
@Telltak
Telltak / game.py
Created December 9, 2010 21:31
first go at homework for lpthw ex 35
from sys import exit
items = ["swooping sword", "nutritious nuggets"]
options = ["help", "look around"]
health = 100
def start():
print "You wake up in a room.\nWhat do you do?"
start_options = options
<html><body>
<?php
function best_tweet($user){
$tweet_score=0;
$tweett="";
foreach ($user->tweets as $tweet){
if ($tweet->xp_value>$tweet_score){
$tweett=json_decode(file_get_contents("http://api.twitter.com/1/statuses/show/".$tweet->tweet_id.".json"))->text;
$tweet_score=$tweet->xp_value;
}
<html>
<head>
<style>
ul {
list-style: none;
padding: 0;
margin: 0;
}
.first, .second, .third{
width:100px;
<!doctype html>
<html>
<head>
<title>canvas test</title>
<style>
#man1 {
background-image: url(man1.png);
width: 100px;
height: 100px;
}
<!doctype html>
<html>
<head>
<title>canvas test</title>
<style>
#man1 {
width: 100px;
height: 100px;
}
</style>
package PROJECT!;
import android.app.Activity;
import net.unto.twitter.Api;
import net.unto.twitter.TwitterProtos.Status;
import android.os.Bundle;
import android.widget.TextView;
public class inkstorm extends Activity
{