This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_credit_card(): | |
return input('Number: ') | |
def confirm_CC(credit_card_number): | |
# Clean up any dashes or other non-numeric characters from the credit card number | |
cc = ''.join(filter(str.isdigit, credit_card_number)) | |
# check Luhn’s Algorithm | |
sum = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cents = -1 | |
while cents < 0: | |
cents = input("Change owed: ") | |
cents = int(cents) | |
coins = 0 | |
while cents >= 25: | |
cents -= 25 | |
coins += 1 | |
while cents >= 10: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cs50 | |
def main(): | |
height = get_height() | |
print_pyramid(height) | |
def get_height(): | |
height = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulate a sports tournament | |
# thanks to ymeng979 on Github for pointing me in the right direction | |
# https://gist.github.com/ymeng979/69d040ce428fa957d3584f541836e394 | |
import csv | |
import sys | |
import random | |
# Number of simluations to run | |
N = 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
menu = { | |
"Baja Taco": 4.00, | |
"Burrito": 7.50, | |
"Bowl": 8.50, | |
"Nachos": 11.00, | |
"Quesadilla": 8.50, | |
"Super Burrito": 8.50, | |
"Super Quesadilla": 9.50, | |
"Taco": 3.00, | |
"Tortilla Salad": 8.00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Jar: | |
def __init__(self, capacity=12): | |
if capacity < 0: | |
raise ValueError("Jar size too small") | |
self._capacity = capacity | |
self._size = 0 | |
def __str__(self): | |
return '🍪' * self.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cs50 import get_string | |
from pyfiglet import Figlet | |
import random, sys | |
Figlet = Figlet() | |
fonts = Figlet.getFonts() | |
# if no arguments provided, pick random font | |
if len(sys.argv) == 1: | |
f = random.choice(Figlet.getFonts()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cs50 import get_string | |
try: | |
greeting = get_string("What say you? ") | |
character = greeting[0] | |
if greeting.lower() == "hello": | |
print("$100") | |
elif character.lower() == 'h': | |
print("$20") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implements a dictionary's functionality | |
// This HASH function uses the single first letter of the word, and is the slowest... | |
#include <ctype.h> | |
#include <math.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implements a dictionary's functionality | |
// This HASH function uses the first two letters of the word, and is faster than a single letter... | |
// includes the typedef of struct hashindex in dictionary.h | |
// | |
// typedef struct hashindex | |
// { | |
// int first; | |
// int second; | |
// } |
NewerOlder