Skip to content

Instantly share code, notes, and snippets.

View sunnyeyez123's full-sized avatar

Jasmine Lawrence sunnyeyez123

View GitHub Profile
@sunnyeyez123
sunnyeyez123 / AreaCalculator.py
Created October 20, 2017 05:38
I am just getting into Python to ease myself back into writing code more regularly. I made this program in a Codecademy freeform project. I want to expand it to different shapes.
'''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)
@sunnyeyez123
sunnyeyez123 / NumberGuess.py
Created October 20, 2017 07:31
Here's another Codecademy project. I liked this one more because it's a game. I'm not sure how to add to this. Any ideas?
'''This is a number guess game. If the user guesses higher than the sum of the dice rolled they win!'''
from random import randint
from time import sleep
def get_user_guess():
user_guess = int(raw_input("Guess a number: "))
return user_guess
def roll_dice(number_of_sides):
@sunnyeyez123
sunnyeyez123 / RPS.py
Created October 21, 2017 06:31
A basic game of Rock, Paper, Scissors. Maybe i'll extend to to add Lizard and Spock!
'''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):
@sunnyeyez123
sunnyeyez123 / Calendar.py
Created October 22, 2017 06:09
This is a simple calendar you interact with via command line. You currently can't add dates in the past. I still need to do some testing here. Any feature requests?
'''This is a program that allows a user to view their calendar, add events,update events and delete events'''
from time import sleep, strftime
NAME = "Jasmine"
calendar = {}
def welcome():
print "Welcome, " + NAME
print "THe calendar is opening..."
@sunnyeyez123
sunnyeyez123 / rgb2hex.py
Created October 22, 2017 18:39
I made an RGB <-> Hex Converter. This is another Codecademy project. I really liked that they linked to resources on Wikipedia.
def rgb_hex():
INVALID_MSG = "Invalid input. Please try again"
red = int(raw_input("Enter a value for red: "))
if red < 0 or red > 255:
print INVALID_MSG
return
green = int(raw_input("Enter a value for green: "))
if green < 0 or green > 255:
print INVALID_MSG
return
@sunnyeyez123
sunnyeyez123 / bankaccount.py
Last active November 2, 2017 06:49
This wasn't that tricky. I think I will modify this behave more like an ATM than just an account. It will allow the user to interact and specify withdraw/deposit amounts. I will also require a pin for their account. I can make it so different users can store their pins.
''' 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)
@sunnyeyez123
sunnyeyez123 / dna.py
Created October 24, 2017 06:41
This is a DNA analysis program. It helps you determine the suspect that committed a crime by matching their DNA samples to a sample found at a crime scene. Comment below if you're able to determine who the culprit is!
'''This is a program that tests the DNA sequences of 3 suspects and helps you determine which one is the likely culprit based on how many codon matches their sample contains'''
sample = ['GTA','GGG','CAC']
def read_dna(dna_file):
dna_data = ""
with open(dna_file, "r") as f:
for line in f:
dna_data += line
return dna_data
@sunnyeyez123
sunnyeyez123 / CharacterInput.py
Last active November 1, 2017 05:14
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. Extras: Add on to the previous program by asking the user for another number and printing out that many copies of the previous message.
'''Character Input Create a program that asks the user to enter their name and
their age. Print out a message addressed to them that tells them the year that
they will turn 100 years old.
Extras:
Add on to the previous program by asking the user for another number and printing
out that many copies of the previous message.
Source:http://www.practicepython.org/
'''
@sunnyeyez123
sunnyeyez123 / Even_or_Odd.py
Last active November 1, 2017 05:13
Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2? Extras: If the number is a multiple of 4, print out a different message. Ask the user for two numbers: one number to check (call it num) and one number t…
''' Ask the user for a number. Depending on whether the number is even or odd,
print out an appropriate message to the user. Hint: how does an even / odd
number react differently when divided by 2?
Extras:
If the number is a multiple of 4, print out a different message.
Ask the user for two numbers: one number to check (call it num)
and one number to divide by (check). If check divides evenly into num, tell that to the user. If not,
@sunnyeyez123
sunnyeyez123 / List_Less_Than_Ten.py
Last active November 1, 2017 05:13
Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list that are less than 5. Extras: Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in it and print out this new list. Write this in one lin…
'''
Take a list, say for example this one:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
and write a program that prints out all the elements of the list that are less than 5.
Extras:
Instead of printing the elements one by one, make a new list that has all the