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 fizzbuzz(stop: int): | |
| """On multiples of 3, print 'fizz' | |
| On multiples of 5, print 'buzz' | |
| On multiples of both, print 'fizzbuzz' | |
| For all other numbers, print the number | |
| """ | |
| result = [] | |
| for x in range(1, stop+1): | |
| if x % 15 == 0: | |
| result.append('fizzbuzz') |
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 dice_distribution(num_sides: int) -> dict[int, float]: | |
| """ | |
| Get the distribution of possible results of two thrown dice | |
| """ | |
| distribution = {} | |
| for x in dice_generator(num_sides): | |
| for y in dice_generator(num_sides): | |
| value = x + y | |
| distribution.setdefault(value, 0) | |
| distribution[value] += 1 |
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 csv | |
| with open('cancel.csv') as f: | |
| reader = csv.DictReader(f) | |
| words = {} | |
| for row in reader: | |
| reason = row['Reason'] | |
| if reason == 'System cancelled - non payment': | |
| continue |
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 typing import Optional | |
| from collections import deque | |
| class Node: | |
| def __init__(self, value: int): | |
| self.value = value | |
| self.left = None | |
| self.right = None | |
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 requests | |
| import base64 | |
| from datetime import datetime | |
| def get_access_token(): | |
| """Get a client credentials token.""" | |
| endpoint = "https://api.ramp.com/developer/v1/token" | |
| client_id = "<client_id>" | |
| client_secret = "<client_secret>" |
OlderNewer