Skip to content

Instantly share code, notes, and snippets.

View sojohnnysaid's full-sized avatar
💾

John James sojohnnysaid

💾
View GitHub Profile
@sojohnnysaid
sojohnnysaid / helpers.py
Created November 23, 2019 21:46
similarities less helpers.py, and index.html
from nltk.tokenize import sent_tokenize
def lines(a, b):
"""Return lines in both a and b"""
(a, b) = (a.split('\n'), b.split('\n'))
# TODO
return [line for line in a if line in b]
@sojohnnysaid
sojohnnysaid / caesar.py
Created November 16, 2019 12:10
caesar python version
import sys
if len(sys.argv) != 2:
print("Usage: python3 caesar.py key")
sys.exit(0)
key = int(sys.argv[1])
message = input("enter a secret message: ")
def cipher(letter, key):
@sojohnnysaid
sojohnnysaid / cash.py
Created November 14, 2019 13:52
cs50 cash in python
cash = float(input("please enter cash amount to break down into coins (example 1.25): "))
coins = {"quarters": .25,"dimes":.10,"nickels":.05,"pennies":.01}
for key, coin in coins.items():
(coins[key], cash) = (divmod(cash,coin)[0], round(divmod(cash,coin)[1],2))
print(coins)
@sojohnnysaid
sojohnnysaid / mario_get_wrecked.py
Created November 13, 2019 22:03
mario pyramid getting slayed by python
height = int(input("enter a number for your mario pyramid: "))
for i in range(2, height+2):
print(('#'*i).rjust(height+1), end=" ")
print('#' * i)
@sojohnnysaid
sojohnnysaid / css_getting_started.html
Last active January 19, 2021 22:57
simple css example
<!DOCTYPE html>
<html>
<head>
<title>css example</title>
<!-- starting css rules -->
<style type="text/css">
/*css comment*/
button{
font-size: 17px;
@sojohnnysaid
sojohnnysaid / python_decorators_getting_started.py
Last active January 19, 2021 22:57
getting started with python decorators
def plusNineThousandDecorator(function):
def wrapper(number):
return function(number) + 9000
return wrapper
@plusNineThousandDecorator
def returnPositiveNumber(number):
if number > 0:
return number
@sojohnnysaid
sojohnnysaid / python_classes_objects_getting_started.py
Last active January 19, 2021 22:57
Python getting started with classes and objects
from cs50 import get_string
from student import Student
# Space for students
students = []
# Prompt for students' names and dorms
for i in range(3):
name = get_string("name: ")
dorm = get_string("dorm: ")
@sojohnnysaid
sojohnnysaid / python_compare_strings.py
Created November 3, 2019 12:57
python compare two strings
#compare two strings from user input
from cs50 import get_string
import sys
def main():
stringOne = get_string("enter string one: ")
stringTwo = get_string("enter string two: ")
if stringOne != stringTwo:
print("They are NOT the same!")
@sojohnnysaid
sojohnnysaid / python_linear_search_menu.py
Created November 3, 2019 02:59
Linear search in python
# Linear search
import sys
from cs50 import get_string
def main():
# dictionary of menu items
lookup = ["pancakes", "eggs", "bacon", "coffee"]
@sojohnnysaid
sojohnnysaid / python_initial_generator.py
Last active January 19, 2021 22:57
Python initial generator using regular expressions
#Extract users initials
from cs50 import get_string
import re
def main():
userName = get_string("enter full name: ")
print(getInitials(userName))