diff --git a/mcb.bak b/mcb.bak new file mode 100644 index 0000000..c034909 --- /dev/null +++ b/mcb.bak @@ -0,0 +1,2 @@ +'rename', (512, 21) +'software', (1024, 34) diff --git a/mcb.dat b/mcb.dat new file mode 100644 index 0000000..1199a99 Binary files /dev/null and b/mcb.dat differ diff --git a/mcb.dir b/mcb.dir new file mode 100644 index 0000000..c034909 --- /dev/null +++ b/mcb.dir @@ -0,0 +1,2 @@ +'rename', (512, 21) +'software', (1024, 34) diff --git a/practice_projects/.vscode/settings.json b/practice_projects/.vscode/settings.json deleted file mode 100644 index f3aef05..0000000 --- a/practice_projects/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "python.pythonPath": "/usr/local/bin/python3", - "python.linting.enabled": true, - "python.linting.pylintEnabled": false, - "python.linting.pep8Enabled": true, - "python.linting.pep8Path": "/usr/local/bin/pep8", - "python.linting.lintOnSave": true, - "python.formatting.provider": "yapf", - "python.formatting.yapfPath": "/usr/local/bin/yapf" -} \ No newline at end of file diff --git a/practice_projects/BulletPointAdder.bat b/practice_projects/BulletPointAdder.bat deleted file mode 100644 index ec25107..0000000 --- a/practice_projects/BulletPointAdder.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe BulletPointAdder.py %* -@pause \ No newline at end of file diff --git a/practice_projects/CharacterPictureGrid.bat b/practice_projects/CharacterPictureGrid.bat deleted file mode 100644 index 45d6018..0000000 --- a/practice_projects/CharacterPictureGrid.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe CharacterPictureGrid.py %* -@pause \ No newline at end of file diff --git a/practice_projects/Collatz.bat b/practice_projects/Collatz.bat deleted file mode 100644 index 04ce70f..0000000 --- a/practice_projects/Collatz.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe Collatz.py %* -@pause \ No newline at end of file diff --git a/practice_projects/CommaConnection.bat b/practice_projects/CommaConnection.bat deleted file mode 100644 index 081f522..0000000 --- a/practice_projects/CommaConnection.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe CommaConnection.py %* -@pause \ No newline at end of file diff --git a/practice_projects/DisplayInventory.bat b/practice_projects/DisplayInventory.bat deleted file mode 100644 index cfb4012..0000000 --- a/practice_projects/DisplayInventory.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe DisplayInventory.py %* -@pause \ No newline at end of file diff --git a/practice_projects/Password.bat b/practice_projects/Password.bat deleted file mode 100644 index 66c1cdd..0000000 --- a/practice_projects/Password.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe Password.py %* -@pause \ No newline at end of file diff --git a/practice_projects/PhoneAndEmail.bat b/practice_projects/PhoneAndEmail.bat deleted file mode 100644 index 41daef3..0000000 --- a/practice_projects/PhoneAndEmail.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe PhoneAndEmail.py %* -@pause \ No newline at end of file diff --git a/practice_projects/TestPrintTable.bat b/practice_projects/TestPrintTable.bat deleted file mode 100644 index 2c8f8b3..0000000 --- a/practice_projects/TestPrintTable.bat +++ /dev/null @@ -1,2 +0,0 @@ -@python.exe TestPrintTable.py %* -@pause \ No newline at end of file diff --git a/practice_projects/mad_libs.py b/practice_projects/mad_libs.py new file mode 100644 index 0000000..4dbffdd --- /dev/null +++ b/practice_projects/mad_libs.py @@ -0,0 +1,39 @@ +#! python3 +''' +mad_libs.py - reads in text files and lets the user add their own text anywhere + the word ADJECTIVE, NOUN, ADVERB, or VERB appears in the text + file. + + For example, a text file may look like this: + ``` + The ADJECTIVE panda walked to the NOUN and then VERB. + A nearby NOUN was unaffected by these events. + ``` + + The program would find these occurrences and prompt the user to + replace them. + + Enter an adjective: + silly + Enter a noun: + chandelier + Enter a verb: + screamed + Enter a noun: + pickup truck + + The following text file would then be created: + ``` + The silly panda walked to the chandelier and then screamed. + A nearby pickup truck was unaffected by these events. + ``` +''' + +import re + +file_name = input("Enter the filename:") +file_read = open(file_name) +content = file_read.read() + +for to_replace in re.compile(r'ADJECTIVE|NOUN|ADVERB|VERB').findall(content): + content.replace(to_replace) diff --git a/practice_projects/mcb.pyw b/practice_projects/mcb.pyw new file mode 100644 index 0000000..1b5ac6a --- /dev/null +++ b/practice_projects/mcb.pyw @@ -0,0 +1,27 @@ +#! python3 +''' +mcb.pyw - Saves and loads pieces of text to the clipboard. +Usage: py mcb.pyw save - Saves clipboard to keyword. + py mcb.pyw delete - Delete the content of keyword. + py mcb.pyw - Loads keyword to clipboard. + py mcb.pyw list - Loads all keywords to clipboard. +''' + +import shelve +import pyperclip +import sys + +mcbShelf = shelve.open("mcb") +# Save clipboard content +if len(sys.argv) == 3: + if sys.argv[1].lower() == 'save': + mcbShelf[sys.argv[2]] = pyperclip.paste() + elif sys.argv[1].lower() == 'delete': + del mcbShelf[sys.argv[2]] +elif len(sys.argv) == 2: + # List keywords and load content + if sys.argv[1].lower() == 'list': + pyperclip.copy(str(list(mcbShelf.keys()))) + elif sys.argv[1] in mcbShelf: + pyperclip.copy(mcbShelf[sys.argv[1]]) +mcbShelf.close() diff --git a/practice_projects/random_quiz_generator.py b/practice_projects/random_quiz_generator.py new file mode 100644 index 0000000..85620be --- /dev/null +++ b/practice_projects/random_quiz_generator.py @@ -0,0 +1,64 @@ +#! python3 +''' +random_quiz_generator.py - creates quizzes with questions and answers + in random order, along with the answer key. +''' + +import random + +capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix', + 'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': + 'Denver', 'Connecticut': 'Hartford', 'Delaware': 'Dover', + 'Florida': 'Tallahassee', 'Georgia': 'Atlanta', 'Hawaii': + 'Honolulu', 'Idaho': 'Boise', 'Illinois': 'Springfield', 'Indiana': + 'Indianapolis', 'Iowa': 'Des Moines', 'Kansas': 'Topeka', + 'Kentucky': 'Frankfort', 'Louisiana': 'Baton Rouge', 'Maine': + 'Augusta', 'Maryland': 'Annapolis', 'Massachusetts': 'Boston', + 'Michigan': 'Lansing', 'Minnesota': 'Saint Paul', 'Mississippi': + 'Jackson', 'Missouri': 'Jefferson City', 'Montana': 'Helena', + 'Nebraska': 'Lincoln', 'Nevada': 'Carson City', 'New Hampshire': + 'Concord', 'New Jersey': 'Trenton', 'New Mexico': 'Santa Fe', + 'New York': 'Albany', 'North Carolina': 'Raleigh', 'North Dakota': + 'Bismarck', 'Ohio': 'Columbus', 'Oklahoma': 'Oklahoma City', + 'Oregon': 'Salem', 'Pennsylvania': 'Harrisburg', 'Rhode Island': + 'Providence', 'South Carolina': 'Columbia', 'South Dakota': + 'Pierre', 'Tennessee': 'Nashville', 'Texas': 'Austin', 'Utah': + 'Salt Lake City', 'Vermont': 'Montpelier', 'Virginia': 'Richmond', + 'Washington': 'Olympia', 'West Virginia': 'Charleston', 'Wisconsin' + : 'Madison', 'Wyoming': 'Cheyenne'} + +# Generate 35 quiz files: +for quizNum in range(35): + # Create the quiz and answer key files. + quizFile = open('capitalsquiz%s.txt' % (quizNum + 1), 'w') + answerKeyFile = open('capitalsquiz_answers%s.txt' % (quizNum + 1), 'w') + + # Write out the header for the quiz. + quizFile.write('Name:\n\nDate:\n\nPeriod:\n\n') + quizFile.write((' '*20) + 'State Capitals Quiz (Form %s)' % (quizNum + 1)) + quizFile.write('\n\n') + + # Shuffle the order of the states. + states = list(capitals.keys()) + random.shuffle(states) + + # Loop through all 50 states, making a question for each. + for questionNum in range(50): + # Get right and wrong answers. + correctAnswer = capitals[states[questionNum]] + wrongAnswers = list(capitals.values()) + del wrongAnswers[wrongAnswers.index(correctAnswer)] + wrongAnswers = random.sample(wrongAnswers, 3) + answerOptions = wrongAnswers + [correctAnswer] + random.shuffle(answerOptions) + # Write the question and the answer options to the quiz file. + quizFile.write('%s. What is the capital of %s?\n' % (questionNum + 1, + states[questionNum])) + for i in range(4): + quizFile.write(' %s. %s\n' % ('ABCD'[i], answerOptions[i])) + quizFile.write('\n') + # Write the answer key to a file. + answerKeyFile.write('%s. %s\n' % (questionNum + 1, 'ABCD'[ + answerOptions.index(correctAnswer)])) + quizFile.close() + answerKeyFile.close() diff --git a/test_mad_libs.txt b/test_mad_libs.txt new file mode 100644 index 0000000..2236cce --- /dev/null +++ b/test_mad_libs.txt @@ -0,0 +1 @@ +The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffected by these events. \ No newline at end of file