Lately I haven’t been working on my coding skills much because I was so busy with the blogs and the children. I am potty training my second child right now and we are facing some difficulties. As he is supposed to begin nursery school in September, the situation is becoming critical…I have been thinking about how I could get more motivated with coding and I got an idea. I want to try to combine my learning to code with another of my interests, literature. So I thought about it and found some literature related python projects.
3 Python projects for writers and book lovers
Novel characters personality test
For this project, you can base yourself on the MBTI test, for instance. You ask some questions to the program user. As he or she answers, you count points for the different aspects of the person’s personality. In the case of the MBTI, this would be Introversion/Extraversion, Sensing/Intuition, Thinking/Feeling and Judgment/Perception. At the end of the test, you obtain the personality type of the person, for instance INFJ or ESTJ. You then have to define a novel character for each personality type.
This exercise will enable you to work on several important points. You will have to print the questions (print) and accept an answer (raw_input). You will have to use if/then statements and count the points (a possibility is to create 4 variables I,N,F,J for instance and set them to 0, then you can add or subtract 1 for each corresponding answer). At the end, you have to translate this in a final result and print this result.
You can imagine different alternatives to this exercise. You can keep the MBTI inspired structure and change the items associated to each personality type. So you can for instance write following programs: “Which book is the best for your personality type?” or “Which famous writer are you like?”
Novel plot generator
This is an exercise I already tried and which was very funny. The goal of this exercise is to obtain a randomly generated novel plot each time you run the program. As you can choose the elements that would come randomly, you can include elements that match to your writing universe (or not, if you want to obtain very different stories).
For this exercise, you will have to work with lists. You can for instance create a list for the name of your character. This would look like this: Charactername1 = [“Marie”, “Ariane”, “Sophie”, “Judith”, “Claire”]. Another important point of the exercise is to obtain random elements from each list. Do not forget to import the random module! Then, you can for each list get a random element. This would look like this: random.choice(Charactername1). When you finally print all elements (possibly completed with texts that do not change), you get your story.Here too, there are different possibilities.
You can focus on a specific genre, such as romance or fantastic. Or you can include elements from very different genres, so you can get very weird texts such as “After the death of her husband, Claire, a famous singer, meets an attractive werewolf at a party on a space ship.”
Another possibility is to create instead of a plot generator a character name generator. This can be useful if you are writing fantastic stories and your characters have very specific types of names. You then would create lists of syllables which you would randomly combine.
Text adventure game
This is a project that can be done on a rather basic way but that can also be extended to a much more complicated project. I have not tried this project yet but would like to try it. I have found a several pages article in an IT magazine which I plan to use as support.
For this project, you need to print some text (use print), and offer the player some alternatives to choose from. For instance, let the player choose whether he or she wants to open the red door or the blue door (use raw_input to give him or her the possibility to enter his or her choice). You will also have to work with if/else statements.
You can imagine several ways to make the game more interesting: you can for instance assign a sum of money to the player which will vary according to his or her actions (buying an object for instance) or you can introduce some random elements.