- The password detection program
- Generating Random quiz file
- Mad Libs
- Selective Copy
The Password detection Program
password=input('Enter your password')
if charRegex.findall(password) == :
print('Password must contain atleast 8 characters')
print('Password must contain atleast one digit')
print('Password must contain atleast one uppercase letter')
print('Password must contain atleast one letter')
print("The password is strong.Good Job!")
while not passStrong:
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 .
quizFile=open('Capitalquiz%s.txt' %(quiznum +1) , 'w+')
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:
Enter a noun:
Enter a verb:
Enter a noun:
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 !