You are on page 1of 5

1.

Remove Duplicates Function


Automation is a huuuuge part of Python’s playbook and an equally big part of why programmers love
the language so much. When it comes to programming and web development (or data science or
machine learning or any of the other fields Python is used for), being able to automate processes that
would otherwise take forever to complete by hand is CRUCIAL.

2. Magic 8 Ball
Am I dating myself by saying I loved Magic 8 Balls as a kid? Well, if you no longer have yours (maybe
because, like me, you smashed it to see what that murky liquid was inside), you can recreate the 8 Ball
logic with this classic Python script example(opens in a new tab)!

3. Pig Latin Translator


Do ouyay peaksay Igpay Atinlay?

4. Use Python to Send Email


As you start working with scripting languages like Python or JavaScript, you’ll realize what an
important role they play in a lot of the web functions we take for granted. Emails are a perfect example.
Business emails rely on automation. When a user signs up for a product on your site, for instance, you
want them to receive a confirmation email…but you DON’T want to be scheduling and sending each of
those emails by hand.
Developers use scripting languages like Python to make that automation happen. Python code examples
like this Python script(opens in a new tab) illustrate how Python can automatically schedule and send
those emails so you won’t have to.

5. Temperature Conversion Program


Is there anything more embarrassing than someone in Europe telling you it’s 32 degrees out, and not
knowing that’s hot not cold? Well, there probably is, but still. Thankfully, we live in the internet age,
where web applications let us convert these kind of numbers at the touch of a button! Python
programming examples, like this temperature conversion program(opens in a new tab), show how to
script a basic conversion script from Celsius to Fahrenheit (and vice versa), something you can recreate
for automating any kind of system conversion program.

6. Convert KM/H to MPH converter


This Python script example(opens in a new tab) follows the same premise as the temperature
conversion program above, but in this case, it’s a Python script used for converting kilometers per hour
to miles per hour. Compare the two programs so you can get a sense of how to use different methods
and inputs to achieve a similar result.

7. Greatest Common Divisor Script


We often say that the tech industry isn’t nearly as math-heavy as outsiders tend to think it is. Part of
that is because most of the heavy computational lifting is done for you by machines. Still, you DO need
to tell machines what to do and how to do before letting them loose. (This sounds like the start of a
classic “robots take over the world” film…).
Python scripts like this greatest common divisor script(opens in a new tab) are perfect examples of how
— once you use Python to give machines a clear set of instructions — they’ll spit out the
computational data you’re looking for till the end of time.

8. Search a Computer For Specific Files


If you’re looking for a particular file or type of file on a computer, the last thing you want to do is hunt
and peck your way there. And that means — if you find yourself working on an application or software
program that needs to be able to find files — you’ll need a way to automate the process. So how do you
do that? This Python script example(opens in a new tab) will give you some clues as to what it takes to
build a feature for searching individual files and files of a specific type.

9. Check Your External IP Address


Needing to know what your external IP address is one of those things that doesn’t come up everyday…
until it does. Here’s a Python script example(opens in a new tab) that shows how easy it is to use
Python for these otherwise tedious kind of tasks.

10. Random Password Generator


Trying to create a website or a mobile app that’s capable of generating random user passwords?
Then this is the Python script(opens in a new tab) for you! Dig into this code and see how to generate
passwords and how you can change the rules to fit your own specific requirements.

11. Username Prompt


Simple (but effective) Python code examples (like this script for a username prompt(opens in a new
tab)) are a good starting point for building up to more complicated scripts and functions.

12. Grocery Calculator


Here’s a Python script example(opens in a new tab) that shows exactly how useful Python can be for
everyday tasks. Trying to keep track of your grocery budget?
There’s a Python script for that! This grocery calculator uses Python code to track and tally the costs of
entered food items. It’ll do your addition and subtraction for you, so no need to worry about missing a
single decimal somewhere.

13. Tweet Search


Ever tried looking for an individual tweet from a Twitter account you follow? Scrolling, and scrolling,
and scrolling, and WHOOPS..accidentally ending up back at the top of the page? NOT COOL. Let this
Python script example(opens in a new tab) makes things easier for you by automating that search
function.

14. Convert to Seconds


Continuing in the vein of Python programming examples that automate measurement conversions, this
Python script(opens in a new tab) converts hours into seconds…again, something you can certainly do
by hand, but why would you when you know how to script with Python?

15. Dice Roller


Whether it’s board game or casino night at home and you’re all out of dice, or you just need a random
number generated between 1-6 (or any range you’d like if you tweak the code), this Python script
example(opens in a new tab) has virtual dice rolling on lockdown.

16. Vowel Remover Function


File this one under “Python programming examples that show how slick Python is for isolating specific
data.” This script(opens in a new tab) identifies all vowels in a field of text and removes them.

17. Hypnosis Generator


You are getting verrrrry sleeeeepy…no, not because you’re 17 entries deep in this list, but because you
just checked out this Python script example(opens in a new tab) — a hypnotism generator! Yeah, it
sounds like a joke, BUT if you explore this code you’ll see how to use Python to prioritize data and
produce different results from the same date pool depending on your parameters.

18. Guessing Game


There are other gamified Python code examples on this list, but this Python script(opens in a new
tab) adds an extra element. Sure, it generates a random number that the user is asked to guess, but it
also includes a loop that causes the script to repeat itself UNTIL the user actually inputs the correct
number.
19. Fizz Buzz Solution
And over here we have your standard Fizz buzz solution, which is a super common interview question.
Check out this Python script example(opens in a new tab).

This script prints the numbers 1-100, but for multiples of 3 prints “Fizz” instead of the number and for
multiples of 5 prints “buzz.”

20. Color Gradients and Intermediaries


This handy Python script example(opens in a new tab) shows how to use Python to calculate that
elusive color information like gradients and intermediaries.

21. Get All Website Links Function


Ever been tasked with finding all the links on a specific website and started seeing double as you pored
over the screen making sure you weren’t missing any? The beauty of scripting with Python is that you
could have just run this Python script example instead(opens in a new tab), and extracted each link
automatically from the sea of data.

22. Average Score Calculator


This super simple Python script example(opens in a new tab) asks users to input three scores and then
promptly produces the average. Of course, you can add more numbers by adjusting the code (as well as
more complicated mathematical functions), but this gives a sense of Python’s computational powers.

23. Hangman Game


Oh, Hangman. A game played on the back of many a napkin and kid’s menu during meals out in my
youth. This Python script example(opens in a new tab) breaks down the mechanics of the Hangman
game and turns it into a digital session of guessing variables.

24. Number Reverser


We continue our list with Python programming examples that highlight fun with numbers. This Python
number reverser script(opens in a new tab) will reverse any given number. So, 1234 becomes 4321.

25. Print Odd Numbers in a Given Range


This is another simple case of using Python to automate a task that would be dull and time-consuming
if done manually. Looking for a list of odd numbers in a given range? Simply execute this Python script
example(opens in a new tab) and BOOM! Mission accomplished.
26. Print All Integers That Aren’t Divisible by Either 2 or 3 and
Lie between 1 and 50
Ready for Python code examples that get even wilder with their mathematical parameters? If you’re
looking to print all integers that aren’t divisible by either 2 or 3 (AND lie between 1 and 50), well my
friend, this is the Python script for you(opens in a new tab)!

In addition to these Python programming examples, there are many other mathematical problems you
can solve using Python. You can use Python to work with complex numbers, factorials, floating point
numbers, lambdas, Fibonacci sequences, data types, and other numeric bits and bobs. Feel free to test
the import math function, play with the range function, and experiment with indexing.
If you love data science, download an IDE and play around with NumPy. There are so many cool ways
that you can explore Python, so we encourage you to try them all.

You might also like