Automate the Boring Stuff - Projects !

Photo by James Pond on Unsplash

Contents:

  1. The password detection program
  2. Generating Random quiz file
  3. Mad Libs
  4. Selective Copy

The Password detection Program

Project: Generating Random Quiz Files

Say you’re a geography teacher with 35 students in your class and you want

to give a pop quiz on US state capitals. Alas, your class has a few bad eggs in

it, and you can’t trust the students not to cheat. You’d like to randomize the

order of questions so that each quiz is unique, making it impossible for anyone

to crib answers from anyone else. Of course, doing this by hand would

be a lengthy and boring affair. Fortunately, you know some Python.

Here is what the program does:

• Creates 35 different quizzes.

• Creates 50 multiple-choice questions for each quiz, in random order.

• Provides the correct answer and three random wrong answers for each

question, in random order.

• Writes the quizzes to 35 text files.

• Writes the answer keys to 35 text files.

This means the code will need to do the following:

• Store the states and their capitals in a dictionary.

• Call open(), write(), and close() for the quiz and answer key text files.

• Use random.shuffle() to randomize the order of the questions and multiple-choice options.

NOTE: The code is written for 10 question papers

Here is the output file,

These are all the files generated on the left side .

The w+ command writes into a file and if the file doesn’t exist , it creates a file. Everytime you run the program you will find that the content generated in the file is being updated

Project : Mad Libs

Create a Mad Libs program that 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:

cute

Enter a noun:

lake

Enter a verb:

screamed

Enter a noun:

garden

The following text file would then be created:

The cute panda walked to the lake and then screamed. A nearby garden was unaffected by these events.

Here is the code snip for it.

Basically , mad.txt is the source file where the changes will take place for our input.

After execution the content in the file will look like,

Project — Selective Copy

Write a program that walks through a folder tree and searches for files with a certain file extension (such as .pdf or .jpg). Copy these files from whatever location they are in to a new folder.import shutil,os

Here is my output which looks like,

That’s it for now ! I will keep on adding more and please let me know if I missed something out or gone wrong !

Thank You !

~kirti

Programmer | Technical content Writer | Lives in India | Wanna go where I can breathe freedom