A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
'''This is a program that calculates the area of triangles and circles''' | |
from math import pi | |
from time import sleep | |
from datetime import datetime | |
now = datetime.now() | |
print "The calculator is starting" | |
print "Current time: %s/%s/%s %s:%s" % (now.month, now.day, now.year, now.hour, now.minute) |
'''This is a simple game of rock, paper, scissors!''' | |
from random import randint | |
from time import sleep | |
OPTIONS = ["R", "P", "S"] | |
LOSER = "You lost." | |
WINNER = "You won!" | |
def decide_winner(user_choice, computer_choice): |
''' A bank account experience that allows you to view the balance of, deposit to and withdraw from your account''' | |
class BankAccount(object): | |
balance = 0 | |
def __init__(self,name): | |
self.name = name | |
def __repr__(self): | |
return "%s's account. Balanace: %.2f" %(self.name, self.balance) |