-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b281d3
commit 5afedd6
Showing
99 changed files
with
49,723 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
print('Enter the name of cat 1:') | ||
catName1 = input() | ||
print('Enter the name of cat 2:') | ||
catName2 = input() | ||
print('Enter the name of cat 3:') | ||
catName3 = input() | ||
print('Enter the name of cat 4:') | ||
catName4 = input() | ||
print('Enter the name of cat 5:') | ||
catName5 = input() | ||
print('Enter the name of cat 6:') | ||
catName6 = input() | ||
print('The cat names are:') | ||
print(catName1 + ' ' + catName2 + ' ' + catName3 + ' ' + catName4 + ' ' + catName5 + ' ' + catName6) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
catNames = [] | ||
while True: | ||
print('Enter the name of cat ' + str(len(catNames) + 1) + ' (Or enter nothing to stop.):') | ||
name = input() | ||
if name == '': | ||
break | ||
catNames = catNames + [name] # list concatenation | ||
print('The cat names are:') | ||
for name in catNames: | ||
print(' ' + name) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#! python3 | ||
# backupToZip.py | ||
# Copies an entire folder and its contents into | ||
# a zip file whose filename increments. | ||
|
||
import zipfile, os | ||
|
||
def backupToZip(folder): | ||
# Backup the entire contents of "folder" into a zip file. | ||
|
||
folder = os.path.abspath(folder) # make sure folder is absolute | ||
|
||
# Figure out the filename this code should used based on | ||
# what files already exist. | ||
number = 1 | ||
while True: | ||
zipFilename = os.path.basename(folder) + '_' + str(number) + '.zip' | ||
if not os.path.exists(zipFilename): | ||
break | ||
number = number + 1 | ||
|
||
# Create the zip file. | ||
print('Creating %s...' % (zipFilename)) | ||
backupZip = zipfile.ZipFile(zipFilename, 'w') | ||
|
||
# Walk the entire folder tree and compress the files in each folder. | ||
for foldername, subfolders, filenames in os.walk(folder): | ||
print('Adding files in %s...' % (foldername)) | ||
# Add the current folder to the ZIP file. | ||
backupZip.write(foldername) | ||
|
||
# Add all the files in this folder to the ZIP file. | ||
for filename in filenames: | ||
if filename.startswith(os.path.basename(folder) + '_') and filename.endswith('.zip'): | ||
continue # don't backup the backup ZIP files | ||
backupZip.write(os.path.join(foldername, filename)) | ||
backupZip.close() | ||
print('Done.') | ||
|
||
|
||
backupToZip('C:\\delicious') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
birthdays = {'Alice': 'Apr 1', 'Bob': 'Dec 12', 'Carol': 'Mar 4'} | ||
|
||
while True: | ||
print('Enter a name: (blank to quit)') | ||
name = input() | ||
if name == '': | ||
break | ||
|
||
if name in birthdays: | ||
print(birthdays[name] + ' is the birthday of ' + name) | ||
else: | ||
print('I do not have birthday information for ' + name) | ||
print('What is their birthday?') | ||
bday = input() | ||
birthdays[name] = bday | ||
print('Birthday database updated.') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
def boxPrint(symbol, width, height): | ||
if len(symbol) != 1: | ||
raise Exception('Symbol must be a single character string.') | ||
if width <= 2: | ||
raise Exception('Width must be greater than 2.') | ||
if height <= 2: | ||
raise Exception('Height must be greater than 2.') | ||
|
||
print(symbol * width) | ||
for i in range(height - 2): | ||
print(symbol + (' ' * (width - 2)) + symbol) | ||
print(symbol * width) | ||
|
||
for sym, w, h in (('*', 4, 4), ('O', 20, 5), ('x', 1, 3), ('ZZ', 3, 3)): | ||
try: | ||
boxPrint(sym, w, h) | ||
except Exception as err: | ||
print('An exception happened: ' + str(err)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
print('Enter the first number to add:') | ||
first = input() | ||
print('Enter the second number to add:') | ||
second = input() | ||
print('Enter the third number to add:') | ||
third = input() | ||
print('The sum is ' + first + second + third) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#! python3 | ||
# Adds Wikipedia bullet points to the start | ||
# of each line of text on the clipboard. | ||
|
||
import pyperclip | ||
text = pyperclip.paste() | ||
|
||
#Separate lines and add stars. | ||
lines = text.split('\n') | ||
for i in range(len(lines)): # loop through all indexes for "lines" list | ||
lines[i] = '* ' + lines[i] # add star to each string in "lines" list | ||
text = '\n'.join(lines) | ||
pyperclip.copy(text) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import time | ||
startTime = time.time() | ||
# Calculate the product of the first 100,000 numbers. | ||
product = 1 | ||
for i in range(1, 100000): | ||
product = product * i | ||
endTime = time.time() | ||
print('The result is %s digits long.' % (len(str(product)))) | ||
print('Took %s seconds to calculate.' % (endTime - startTime)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
print('''Dear Alice, | ||
Eve's cat has been arrested for catnapping, cat burglary, and extortion. | ||
Sincerely, | ||
Bob''') |
Oops, something went wrong.