- What can you do with Python? 5 real-world Python applications
- 5 real-world applications of Python
- 1. Music
- 2. Entertainment
- 5 Cool things You can do with Python
- Introduction
- For Web Development
- Example – Access to the computer file system from mobile
- Automation and Scripting
- Example – Convert CSV to JSON
- Building Games
- Resources to learn
- Example – Hangman in Terminal
- Web Scraping
- Example – Get currency value compared to USD
- Data Science and Machine Learning
- Conclusion
What can you do with Python? 5 real-world Python applications
The word is out on Python. The simplicity, limitless range of external libraries, and committed community of Pythonistas are fundamentals of Python that even a beginner developer has probably heard before. These features have also distinguished Python as the most used programming language in the world, currently [1] .
You’re not here to learn all the reasons why you should learn Python as either your first introduction to coding or your next learning endeavor in a long line of languages. You’re here to be shown why learning Python is worth your time based on the career and project you see in your future. For our purposes, It helps to view Python as a tool. We’ll explore not necessarily the tool itself, but rather all that can be built by that tool. It’s pointless to learn how to grip and strike with a hammer if you don’t have an idea of what to do with it once you achieve proficiency. If you don’t know what your future holds just yet, that’s more than OK. Hopefully, the following sections can provide some inspiration through examples. Many major industries and companies are already using Python’s boundless applications to turn their visions into reality.
Python is a versatile and powerful tool that stretches to every corner of our world. The use cases of Python are in everything from Luke Skywalker’s lightsaber to your tedious health care plan. You don’t know Python until you know what it can do.
5 real-world applications of Python
Python code is in everything. The Python-based libraries and modules that can be freely and easily used in any project make certain that the language can be everywhere. Some examples of these libraries are NumPy for machine learning and Pandas for data analysis. Python and its endless list of libraries are things that even the most different industries and companies have in common. As a tool, Python can lead you down any career path that you could dream of. Let’s take a look at just a few examples of where Python thrives.
1. Music
The Python programming language brings you personalized playlists to brighten up your day. Spotify uses Python to support its back-end web development and data science. Have you ever wondered how Spotify knows exactly what to put in your personalized playlists? You can thank the data analysis capabilities of Python. Over 80% of Spotify’s back-end web development and data analysis processes are written in Python.
Spotify is also a vocal and proud member of the Python community, sponsoring large conferences such as PyCon and local groups such as NYC PyLadies. A thriving company like Spotify doesn’t connect its name to a language so enthusiastically unless it performs sensationally. Spotify is always hiring Python developers. If you’ve always pictured yourself working with music while using your favorite programming language, then these are opportunities you should keep an eye out for in the future.
2. Entertainment
You don’t have to write or act to get into the entertainment business. You can code too! Python appears frequently in the entertainment media industry. Industrial Light and Magic, the visual effects company behind films such as Star Wars and Jurassic Park, has been using Python to run its CGI operating systems and lighting automation for decades. And Netflix has been becoming more and more Python-oriented every year. The company depends on Python to run its Cassandra database. Cassandra clusters and modules are used for automation (including the recommendations page that everybody loves), data analytics, and error monitoring.
Metaflow, a Python web framework, is responsible for machine learning projects at Netflix from the prototype to the production stage. The framework handles millions of data points and organizes them among thousands of CPUs. YouTube was also initially built using mostly Python and still heavily uses it today among other languages. Not just exclusive to Netflix, the machine learning abilities of Python are extensively used in our modern entertainment landscape.
5 Cool things You can do with Python
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.
Python is one of the most loved programming languages.
And why not, you can build from simple maintenance scripts to complex machine learning application. There are many cool things you can do with Python, which you’ll love to learn.
Introduction
Python is a very popular language among developers. It is easy and fun to write scripts to automate and build stuff.
Some of the common use cases are:
- Creating bots
- Scraping websites
- Machine learning, data visualization, and analysis
- Web Development with frameworks like Django and Flask
- Game development with Pygame
- Mobile apps with frameworks like Kivy
In this article, I’ll try to cover multiple domains with examples and show you some of the fun stuff you can do with Python. In case you don’t know python, I’ll recommend learning it!
Let’s get started!
For Web Development
Python has very good support for web development with its frameworks like Django, Flask, and others. It can be used to build server-side web applications and can be integrated with any frontend. Generally, developers use JavaScript in frontend and python for supporting server-side operations. Python is not used directly in browsers.
Django is one of the most popular web frameworks in python. These frameworks provide a package where you have a defined structure, supports database interactions with ease; all this is set up with a minimal setup command. If you want something minimal to start with – I’ll recommend Flask!
Apart from these, Python has a large number of libraries for web development. Some popular ones are –
Some resources to get started with web development in Python –
Example – Access to the computer file system from mobile
You can access your file system by running a file server on your machine. Go to the desired directory that you want to access and run the following command –
# python version >= 3.X python3 -m http.server # If Python version >= 2.X and < 3.X python -m SimpleHTTPServer #default port: 8000
This starts a file server that can be accessed on the same network. To access your files on mobile, simply connect to the same network(wifi or use the phone’s hotspot on a laptop). Now in your phone browser open –
Check your IP by running – ifconfig . Check your local IP (should start with 192.168….)
Suppose your IP is – 192.168.43.155 and you use the default port. Then, you should open –
192.168.43.155:8000 on mobile. You’ll see current directory 🙂
Automation and Scripting
If you are an engineer, you probably will be lazy and want to automate almost everything you can, right?
No worries, python got you covered. There are a ton of things that you can automate with as little as 4-5 lines of code. From setting cron jobs and reminders to downloading your favorite youtube videos, you can do it all with a couple of lines in python.
Some awesome scripts and packages you can start using –
Example – Convert CSV to JSON
You can convert the CSV file to JSON with just 1 command in python!
python -c "import csv,json;print json.dumps(list(csv.reader(open('your_csv_file.csv'))))"
Replace with your filename.csv, and you will get a JSON output!
Building Games
Python supports developing games. Its Pygame library is highly useful. It supports art, music, sound, video, and multimedia projects to be built with it. You can even make cross-platform games using Kivy, which runs on Windows, Mac, Linux, Android, and iOS.
Resources to learn
Example – Hangman in Terminal
Here is a simple python program which lets you play hangman game in the terminal. Code can be shortened a lot, and I’ll leave that as an exercise to you!
# hangman.py #importing the time module import time import random turns = 10 print "Hello, Let's play hangman! You will have " + str(turns) + " turns!" print "" # delay time.sleep(0.5) # set of words to guess from wordList = ["geekflare", "awesome", "python", "magic"] word = random.choice(wordList) guesses = '' # loop till no turns are remaining while turns > 0: wrong = 0 for char in word: if char in guesses: print char, else: print "_", wrong += 1 print("\n") if wrong == 0: print "You won :)" break print guess = '' if len(guess) < 1: guess = raw_input("Guess a character or enter the correct word: ")[0] guesses += guess if guess not in word: turns -= 1 print "Wrong" print "You have", + turns, ' turns left!' if turns == 0: print "You Lose :("
The output would look something like –
Web Scraping
You see a lot of data every day across multiple sites. Think how cool it would be if you can access that data easily; that is what web scraping is, and python makes it even easier with its amazing support and libraries. Data on the web is unstructured, and python provides an easy way to parse and consume this data and even do further analysis and operations.
Some popular scraping libraries are:
Let me show you an example on how you can scrape currency values from a website – x-rates.com
Example – Get currency value compared to USD
Let’s use scraping in python to fetch currency values –
import requests from bs4 import BeautifulSoup URL = "https://www.x-rates.com/table/?from=USD&amount=1" r = requests.get(URL) soup = BeautifulSoup(r.content, 'html.parser') ratelist = soup.findAll("table", )[0].findAll("tbody") for tableVal in ratelist: trList = tableVal.findAll('tr') for trVal in trList[:6]: print(trVal.text)
This returns how much 1 USD equals in other currencies.
Data Science and Machine Learning
DS and ML are the most trendy topics these days. These technologies are the future of computer science.
Python is well suited for data manipulation, analysis, and implementing complex algorithms. Data parsing and visualization are usually simple functions or a few lines of code with python libraries like NumPy, scipy, scikit-learn, etc.
Python can be used in data-intensive and machine learning application using a lot of popular libraries like –
There are a lot of deep learning tools that support python. Some popular libraries and frameworks are –
One of the other reasons python is used is even complex machine learning models can be achieved with 20-40 lines of code. Check this tutorial on how easily visualizations can be done in python.
Conclusion
The tutorial discussed various domains in which python can be used. Here, I present a few of the cool and simple examples for the purpose of the demonstration, but there are a lot more awesome applications and tools you can build with Python. I hope you learned something new!
Keep exploring. Keep learning!