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 random import shuffle | |
| class Deck: | |
| def __init__(self): | |
| self.cards = [] | |
| for i in range(2, 15): | |
| for j in range(4): | |
| self.cards.append(Card(i, j)) | |
| shuffle(self.cards) |
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 Game: | |
| def __init__(self): | |
| name1 = input("p1 name ") | |
| name2 = input("p2 name ") | |
| self.deck = Deck() | |
| self.p1 = Player(name1) | |
| self.p2 = Player(name2) | |
| def wins(self, winner): | |
| w = "{} wins this round" |
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 re | |
| text = """Giraffes have aroused | |
| the curiosity of __PLURAL_NOUN__ | |
| since earliest times. The | |
| giraffe is the tallest of all | |
| living __PLURAL_NOUN__, but | |
| scientists are unable to | |
| explain how it got its long |
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 urllib.request | |
| from bs4 import BeautifulSoup | |
| class Scraper: | |
| def __init__(self, site): | |
| self.site = site | |
| def scrape(self): | |
| r = urllib.request.urlopen(self.site) |
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 time | |
| import random | |
| class Queue: | |
| def __init__(self): | |
| self.items = [] | |
| def is_empty(self): | |
| return self.items == [] |
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 fizz_buzz(): | |
| for i in range(1, 101): | |
| if i % 3 == 0 and i % 5 == 0: | |
| print("FizzBuzz") | |
| elif i % 3 == 0: | |
| print("Fizz") | |
| elif i % 5 == 0: | |
| print("Buzz") | |
| else: | |
| print(i) |
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 ss(number_list, n): | |
| found = False | |
| for i in number_list: | |
| if i == n: | |
| found = True | |
| break | |
| return found |
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 is_palindrome(word): | |
| word = word.lower() | |
| return word[::-1] == word | |
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 is_anagram(w1, w2): | |
| w1 = w1.lower() | |
| w2 = w2.lower() | |
| return sorted(w1) == sorted(w2) | |
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 count_characters(string): | |
| count_dict = {} | |
| for c in string: | |
| if c in count_dict: | |
| count_dict[c] += 1 | |
| else: | |
| count_dict[c] = 1 | |
| print(count_dict) | |