Skip to content

Instantly share code, notes, and snippets.

View odanga94's full-sized avatar

Odanga Ochieng' odanga94

  • Kenya
View GitHub Profile
@odanga94
odanga94 / Calendar.py
Created April 30, 2017 06:54
CodeAcademy python Lesson: Command line Calendar
"""This program creates a calendar that the user can interact with from the command line. It allows the user to: view the calendar, add an event to the calendar, update an existing event, delete an existing event"""
from time import sleep, strftime, localtime
USER_NAME = "Odanga"
calendar = {}
def welcome():
print("Welcome to MyCalendar %s") %(USER_NAME)
print("MyCalendar is starting...")
sleep(1)
print("Today's date is: " + strftime("%A %B %d, %Y", localtime()))
@odanga94
odanga94 / NumberGuess.py
Last active April 29, 2017 11:06
CodeAcademy Lesson: Number Guess
"""This program randomly rolls a pair of dice and adds the values of the roll.
It then asks the user to guess a number, compares the user's guess to the total value and finally decides whether the winner is the user or the program and informs the user who the winner is"""
from random import randint
from time import sleep
def get_user_guess():
user_guess = int(raw_input("Enter your guess:"))
return user_guess
@odanga94
odanga94 / AreaCalculator.py
Created April 29, 2017 11:00
Code Academy python lesson: Area Calculator
"""This program prompts the user to select either a circle or a triangle and returns the area of that shape"""
from math import pi
from time import sleep
from datetime import *
now = datetime.now()
print "Welcome to Calculator 1.0"
print "%s/%s/%s %s:%s" %(now.month, now.day, now.year, now.hour, now.minute)
sleep(1)
@odanga94
odanga94 / RPS.py
Last active April 29, 2017 11:07
Codeacademy Python Lesson: Rock, Paper, Scissors
"""This is a Rock-Paper-Scissors game. It prompts the user to select either Rock, Paper or Scissors. The computer then randomly selects either rock, paper or scissors and then compares the user's choice and the computer's choice. Finally it determines if the user has won and informs the user of the outcome"""
from random import randint
from time import sleep
options = ["R", "P", "S"]
LOSE = "You lost!"
WIN = "You Win!"
def decide_winner(user_choice, computer_choice):
print("%s") %(user_choice)
print("Computer Selecting...")
sleep(1)