4 Python Projects for Beginners

Do you want to learn Python? These 4 Python projects can be completed with one single script file, a limited number of imports and dependencies, and are perfect for beginner programmers. These challenges will help you learn and create some cool scripts that you can use on your own computers. From file sorting and image cropping to cool command line apps, these Python projects will get some work in your portfolio and resume in no time!

Python 3 Basics

Although many of these projects can be created with older versions of Python, we highly recommend that you use the latest version. Your creations will be usable by yourself and people around the world for longer if you avoid older versions.

We recommend also at least knowing the following before you attempt these projects…

  • Declare an integer, string, float, etc.
  • Ask for user input
  • If / Else and switches
  • Evaluate user input types, validity, and values
  • Print values to screen/command line
  • Loops
  • Dependency installations (ex: pip install Pillow)
  • Importing dependencies

#4 Python File Sorting & Moving

Just last week my father asked me for help with the computer in his office. I knew I would be spending some time there, so I even brought my lunch. Upon arrival, I was immediately warned of the sheer number of files on his desktop. Sure enough, I was greeted by dozens of unorganized folders and hundreds of images, documents, and other files. Good thing I know Python!

I decided to write a Python script to handle the organization of his computer. I wrote the script to take all of the documents and put them in one place, and images in another. However, I did not want to recursively do this for his whole computer because although his desktop was messy, the rest of his computer was somewhat well labeled. I wanted to avoid separating documents from related images in the “Africa travel” folder for example.

Let’s see if you can create your own file sorting script with Python! Here’s how you get started…

  • import os to handle operating system related functions
  • import glob to quickly search a working directory (or more) for files matching an extension, or pattern
  • Utilize an array of types to cover the different extensions (example: .jpg, .jpeg, .png, .gif) for each file category you want
  • Use os.rename() or something similar to move the file into the designated folder
  • Use a loop to do all of this quickly, or create a simple input() prompting process for a user to engage with on the command line (example: Move / Stay option for each file)

#3 Python Bulk Image Cropping

Yet again, I had another use for a Python script just the other day. I needed to crop a bunch of images to specific dimensions for use in a client’s website. I could have spent hours manually cropping each image and making sure the aspect ratios were correct, but I knew a Python script could handle this.

Although this is by far the most advanced script in our list of Python projects for beginners, it is definitely possible for anyone who is confident with the Python 3 basics list above.

You must take an entire folder of images and crop them to the desired dimensions. If the image is smaller than the width/height of the other results, the image should be stretched to the new dimensions. Or, you can do what I did and add an option at the beginning of the script that lets you choose whether to skip images that will need to be stretched, and/or skip images that will lose most of their content after the crop (due to aspect ratios).

You can check out my script SmartCropSize.py on GitHub! Feel free to use it as a reference, modify my code, or commit your own to the usefulPython repository!

Whatever you do, here is what you will learn along the way…

  • How to install and import Pillow or a similar library for image handling
  • mkdir() to create a new folder for your cropped images, so you don’t overwrite the originals
  • Check image.size dimensions and decide how the image should be cropped to limit the amount of content lost
  • Utilize final cropping and resizing functions once your crop offsets & dimensions are set
  • Save the new image to a specific folder for cropped images
  • Utilize the input() function in the beginning of your script to store desired width/height for the images. This also helps tremendously with testing your code’s “smart cropping”!

Note: Of course you can do this all a lot easier by just cropping without centering the image pre-crop or having your code decide the smartest way to eliminate content loss… I recommend doing that first and then optimizing your code for all of this so you don’t sit there stumped!

#2 Simple Quiz in Python

You can test your friends and family on any topic you know! Your Python script should be able to use an array of questions & possible answers (with one marked as correct) to allow quiz-takers to type a number or letter for their answer. Of course, you could always ask questions without multiple choice and analyze their answer, but they will have to have great spelling and not use odd synonyms!

Want to follow an easy to understand tutorial? Check out my guide, How to Create a Multiple Choice Quiz With Python 3

Here are some ideas for your first quiz in Python:

  • Generate the number of Points earned or tell the quiz-taker their percentage of correct answers at the end!
  • Offer a mix of multiple choice & open ended questions
  • Trivia game that allows multiple people (amount of players chosen in the beginning) to answer. Compare scores after!
  • Use sections in the quiz to help the quiz-taker understand their strengths and weaknesses (example: Math, Science, History sections)
  • Store quiz results to a file (useful for schools, but may require some custom encryption to prevent cheating / modifying the file)

#1 Ad-Lib Story Generator

Are you good at coming up with some interesting or hilarious stories? Try your hand at an ad-lib story generator with Python! Here’s how it works…

The [animal] [verb] the [noun] after its owner takes it out to the [place] because it is feeling [emotion]. All of a sudden, a [animal] [verb] through the sky on a spaceship to [verb] with [name].

The puppy flies the pencil after its owner takes it out to the beach because it is feeling happy. All of a sudden, a chicken walks through the sky on a spaceship to swim with Tommy.

You simply write some stories, but the verbs, nouns, adjectives, places, names, and anything else you want to leave up in the air can be blank. You simply ask the person using your script to input some text for each value. They will have no idea what the story is until the end.

You can come up with some very ridiculous stories once all the values are inputted and it’s good for your creative juices too! Here’s how you can spice it up!

  • Have multiple stories so you never know which one was randomly selected by your script.
  • Ask the user for nouns/verbs/etc in a random order (but make sure your script keeps track of values) so they can’t detect the order of events.
  • Give your stories alternate endings so it’s hardly ever the same, even if you get the same story twice
  • Use some logic to see if a user-supplied verb is of the right tense (past, future, current, etc)
  • Find a digital thesaurus to change out words before or after the story is generated to make your script even more advanced

Learn to Code in Python 3

If you want some help learning Python, I highly recommend checking out Code Forum. As a community moderator, I help people on the site with their programming skills through tutorials, brainstorming, code analysis, and discussions! If you are struggling to find friends that are as passionate about Python and programming as general, you should definitely check us out!

There are other programming languages and development areas too, so feel free to discuss almost anything you want! And don’t forget to check out these 7 Fun Projects to Code in 1 Day!