This file contains 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
suits = ('Hearts', 'Diamonds', 'Clubs', 'Spades') | |
ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') | |
values = {'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':10, 'Queen':10, 'King':10, 'Ace':11} | |
import random | |
def prepare_deck(): | |
a_deck = [] | |
for s in suits: | |
for r in ranks: |
This file contains 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 Account(): | |
def __init__(self, owner, balance=0): | |
self.owner = owner | |
self.balance = balance | |
def deposit(self, deposit_amt): | |
self.balance += deposit_amt | |
print(f'Hello {self.owner}') | |
print(f'Deposit of {deposit_amt} processed') |
This file contains 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 random | |
def display_board(a_board): | |
print(a_board[7] + '|' + a_board[8] + '|' + a_board[9]) | |
print('-'*5) | |
print(a_board[4] + '|' + a_board[5] + '|' + a_board[6]) | |
print('-'*5) | |
print(a_board[1] + '|' + a_board[2] + '|' + a_board[3]) | |
This file contains 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_primes(n): | |
import math | |
primes_count = 0 | |
for i in range(1, n+1, 2): | |
if i == 1: | |
pass | |
if i == 2: |
This file contains 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 summer_69(mylist): | |
total = 0 | |
add_on = True | |
for i in mylist: | |
if i == 9 and add_on == False: | |
add_on = True | |
elif i == 6: |
This file contains 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 has_33(mylist): | |
for i in range(len(mylist)-1): | |
if mylist[i] == 3 and mylist[i+1] == 3: | |
return True | |
return False |
This file contains 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 myfunc(mystring): | |
templist = [x.lower() for x in mystring] | |
indx = 1 | |
for i in templist[1::2]: | |
templist[indx] = i.upper() | |
indx += 2 | |
return ('').join(templist) |
This file contains 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 operator | |
text_line = input("Type in: ") | |
freq_dict = {} | |
for i in text_line.split(' '): | |
if i.isalpha(): | |
if i not in freq_dict: | |
freq_dict[i] = 1 |
This file contains 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 math | |
x, y = 0, 0 | |
while True: | |
step = input("Type in UP/DOWN/LEFT/RIGHT #step number: ") | |
if step == "": | |
break |
This file contains 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
n = int(input()) | |
divBy7 = [i for i in range(0, n) if (i % 7 == 0)] | |
print(divBy7) | |
def divChecker(n): | |
for i in range(n): | |
if i % 7 == 0: | |
value = True | |
else: | |
value = False |
NewerOlder