DEV Community

Cover image for I am going to automate you with Python | Reverse Python Lab
Rashid
Rashid

Posted on • Updated on

I am going to automate you with Python | Reverse Python Lab

Hey DEV Network!

In this lab, I am going to automate you with Python so you will start to fly end of this experiment.

Before we go on, check my previous post to boost your learning speed, it will help you to code fast and effectively.

Alright! Let's start with pre-lab procedures.

What concept is this lab about?

You will see how Python is expressive, productive and useful in just about any career.

What is the overall purpose of the lab?

The main objective is to help you gain in-depth knowledge of Python programming and show how you can use it in your daily life.

What is special with this lab?

The lab will provide you with great resources to learn Python effectively and step by step.

Initially, let me quickly introduce you what Python is used for.

Python continues to climb the ranks of the world's most popular programming languages not just amongst software engineers but also amongst mathematicians, data analysts, scientists, accountants, network engineers and even kids! It is used across various fields from web and game development to machine learning, AI, scientific computing and academic research. Because it is a multi-purpose language, which means it can be used to build just about anything with the right tools/libraries.

If you constantly have to do boring, repetitive tasks, such as copying files, moving them, uploading them to the server, you can write a Python script to automate all that stuff and save your time. These tasks are simple but time-consuming for humans, and they’re often so trivial or specific that there’s no ready-made software to perform them. Armed with a little bit of Python programming knowledge, you can have your computer do these tasks for you. So you don't have to be a software developer to use Python. You might be an accountant, a mathematician or a scientist and use Python to make your work easier.

I am highly recommending you to read "Automate the Boring Stuff with Python", this book shows you how to use Python to automate tasks like Reading and Writing Files, Web Scraping, Debugging, Organizing Files, Working with Excel, PDF files and CSV files and much more.

"Any sufficiently advanced technology is equivalent to magic.”–Sir Arthur C. Clarke

Now, let's go through our lab!

Python Basics

Python

Python does have a lot going for it in terms of simplicity. In many ways, doing stuff in python is easier, but you still need to search the libraries, learn what's applicable, and work through writing code to achieve whatever issue you're attempting to fix.

Python provides great readability and easy-to-learn syntax that helps beginners use this language of programming. It is intended to be as easy as possible so that more programming time is spent. You will find Python code is so much more readable than any other languages because it is designed to be English like. For instance, The first code example below is written in C++:

#include stdout

int main()
{
    std::cout << "Hello, world!\n";
}
Enter fullscreen mode Exit fullscreen mode

And here’s code with the same output in Python 3:

print("Hello, world!")
Enter fullscreen mode Exit fullscreen mode

Python is supported with excellent self data structures that are different and very useful. They are powerful, you will spend less time to figure out about the data structure and more time to figure out implementing the code.

Here are some great resources to help you learn the basics of Python:

  • Codeacademy — does a good job of teaching basic syntax, and builds
  • Learn Python the Hard Way — a book that teaches Python concepts from the basics to more in-depth programs.
  • Treehouse — My first Python teacher was Kenneth Love from Treehouse Python Boot Camp.
  • Introduction to Python — Learn fundamental concepts for Python beginners that will help you get started on your journey to learn Python. These tutorials focus on the absolutely essential things you need to know about Python.
  • Learn Python - Full Course for Beginners [freeCodeCamp] — This course will give you a full introduction into all of the core concepts in python. Follow along with the videos and you'll be a python programmer in no time!

These is the best resources I have seen so far but if you have better suggestions write down on comment section. Usually paid tutorials are better than free one, because the materials are well organized and the instructors will also provide supports if you encounter problems. But according to the trend in the market, Codecademy is considered the best for beginning willing to learn the basics of coding. For the advanced stages, Treehouse is the best as they actually have the courses that prepare the programmers to code in real-life projects.

Once you learned basics of Python, it is time to build small projects to improve your knowledge. Code Club provides best resources to practice basics of Python with small interesting projects.

Code Club

Web Development with Python

Thanks to all the incredible frameworks that make Python web development fast and simple. The framework is basically a package of packages and modules that provide certain features and can be selectively modified to produce application-specific software.

So how do you choose the right framework? Django and Pyramid are the way to go for full-fledged web applications. For better control and visualization or prototyping an app, Web2py or Flask might be the way to yo. CheeryPy is a must-have for easy, minimalist alternatives. Tornado will handle 10,000 or more concurrent connections to your app at the same time, while Dash is the perfect choice for analytics.

Let's take look powers of Python for web development. I mainly will focus on most popular framework Django.

Used and trusted by many popular companies

Companies like Bitbucket, Instagram, Dropbox, Pinterest, Disqus and others are using Python frameworks like Django and Pyramid in their app growth. These frameworks will manage almost everything you throw at them, and that's part of why Python's web development is so popular.

Disqus, a popular blog comment hosting service, has more than eight billion page views and 45K request per second through Python framework Django.

Top 10 Django Apps and Why Companies Are Betting on This Framework

Should I learn Django in 2019?

Hides complex low-level information

The above-mentioned frameworks are fully-equipped open-source toolkit with extremely customizable architecture, it promotes rapid growth and easy code structure and that is why I recommend Python web development for beginners as well as for the experienced developers.

Time-Saver

Time is money. You will save your gold time by using these frameworks.It is ideal for creating simple prototypes or projects on a budget with brief deadlines.

Web Security

By default, Django prevents most common security mistakes:

  • XSS (cross-site scripting) protection — Django template system by default escapes variables, unless they are explicitly marked as safe.
  • CSRF (cross site request forgery) protection — easy to turn on globally, guarantees that forms (POST requests) are sent from your own site.
  • SQL injection protection — Django uses built-in ORM, thus there is no risk of SQL injection (raw queries are possible, but by no means something that a beginner would need to use).

For more information check Django Security

With the good web framework, however, you don’t have to worry about that because there has been a lot of work put into preventing any misuse of the web application.

I am going to show you resources for learning Django because it is most popular framework of Python and I highly recommending you to start with Django. There is a lot of resources on internet but following tutorials are the best and beginner-friendly for become Full-Stack Python Developer

  • Real Python — This learning path will provide you with the foundational skills you need to become a Python web developer. You will cover the most popular Python web development frameworks like Django and Flask, working with databases, as well as fundamental front-end coding skills like HTML.
  • Simple is Better Than Complex — Stories and Tutorials about Python, Django and Web Development
  • Python and Django Full Stack Web Developer Bootcamp (Udemy) — Learn to build websites with HTML , CSS , Bootstrap , Javascript , jQuery , Python 3 and Django!
  • CodingEntrepreneurs — Coding for Entrepreneurs is a Programming Series for Non-Technical Founders. Learn Django, Python, APIs, Accepting Payments, Stripe, JQuery, Twitter Bootstrap, and much more.
  • The Net Ninja Django Series — Django tutorial by Net Ninja introduce you to what exactly Django is and why we would want to use it as web developers.

Data Science and ML with Python

Data Science with Python

Python is one of the most popular choices for Data Science because of its easier learning curve and useful libraries. Python makes it easier for the user to implement solutions while following the standards of required algorithms.

Python emerging as the leader
Take the case of the tech giant Google that has created the deep learning framework called tensorflow – Python is the primary language used for creating this framework. Its footprint has continued to increase in the environment promoted by Netflix. Production engineers at Facebook and Khan Academy have for long been using it as a prominent language in their environment — Is Python the most popular language for data science?

AI and ML

Imagine a computer which can make decision and predictions based on the data you have given it before.

There are two main reasons why Python is the best for ML or in general AI: its simplicity, as well as the full range of available libraries and frameworks. In consideration of the drawbacks, Python is far from the only choice of languages that can be used in machine learning. Among many others, R, Java™, and C++ are other languages that are used for ML. In addition, if someone just wanted to learn ML concepts, they wouldn't have to write any code at all to get a nice knowledge. To apply the ideas, however, particularly as a start.

Python should be learned by a beginner programmer wishing to work on AI techniques. Even if they discover that they prefer to add another language to their programs later in the process, some knowledge of the language is essential to both understanding prior job and having a head start on constructing their own projects.

Solving a Data Science and ML problems involves data pre-processing, analysis, visualization, predictions, and data preservation. Here is the some powerful statistical and numerical packages of Python:

  • NumPy and pandas (Python Data Analysis Library) allow you to read/manipulate data efficiently and easily.
  • Matplotlib allows you to create useful and powerful data visualizations.
  • Scikit-learn allows you to train and apply machine learning algorithms to your data and make predictions. Also PyBrain and Tensorflow for some neural network
  • Cython allows you to convert your code and run them in C environment to largely reduce the runtime and improve your model performance.
  • BeautifulSoup package for parsing HTML and XML documents. It creates a parse tree for parsed pages that can be used to extract data from HTML, which is useful for web scraping.

Check these gold sources to start your learning path to become great Data Scientist:

  • The Data Science Course 2019: Complete Data Science Bootcamp — Complete Data Science Training: Mathematics, Statistics, Python, Advanced Statistics in Python, Machine & Deep Learning
  • Dataquest — Learn Python, R, SQL, data visualization, data analysis, and machine learning. Try any of 60 free missions now and start your data science journey.
  • Python for Data Analysis — It will cover all the basics, like data aggregations and time series while at the same time take through basic python exercises that will help you learn how to apply Pandas to actual problems.
  • Learn Data Science Tutorial - Full Course for Beginners — Learn Data Science is this full tutorial course for absolute beginners.
  • Fast AI — research lab bundled with courses, an easy-to-use Python library with a huge community.
  • Practical Machine Learning Tutorial with Python — The objective of this course is to give you a holistic understanding of machine learning, covering theory, application, and inner workings of supervised, unsupervised, and deep learning algorithms.

Cybersecurity with Python

Alt Text

Learning a programming language gives you an edge in cybersecurity because it allows for a deeper understanding of how applications function. Having this capability increases your chances of recognizing vulnerabilities and figuring out how to fix them.

Python will allow you to automate tasks and conduct malware analysis. Cybersecurity experts can use Python to create attack simulations, build intrusion detection systems and scan wireless networks without depending on third-party tools. Python is one of the programming languages of choice for people working in the cybersecurity field. It's easy to learn, high-performance and versatile.

Here is the cool cyber resources that will help you to become a ethical hacker:

  • Learn Python & Ethical Hacking From Scratch — Start from 0 & learn both topics simultaneously from scratch by writing 20+ hacking programs
  • Ethical Hacking with Python — Though targeted towards complete beginners, this course also serves as a handy refresher for seasoned programmers for who want to sharpen their coding skills.
  • Python For Ethical Hacking — how to use Python to create network tools and Ethical Hacking scripts. This series will take you from beginner to intermediate/advanced in Python.
  • Cracking Codes with Python — After a crash course in Python programming basics, you’ll learn to make, test, and hack programs that encrypt text with classical ciphers like the transposition cipher and Vigenère cipher.
  • Black Hat Python: Python Programming for Hackers and Pentesters — When it comes to creating powerful and effective hacking tools, Python is the language of choice for most security analysts. But just how does the magic happen?

It is good know at least basics of hacking with Python.

python3 makeDevFly.py
Enter fullscreen mode Exit fullscreen mode

fly with python

I hope you learned something from this lab 😃 and if you found it useful, please share it with friends and family who you think may find it useful too! Join me on social media and as always Stay Connected!🚀

Instagram
Twitter
support me by buying me a cup of coffee😊☕

Top comments (3)

Collapse
 
pottedmeat7 profile image
pottedmeat7

I know there is alot of library support, such as ML, in Python. I just wish all of that was written in Ruby. I really don't enjoy programming in Python that much, it seems to have some major design issues.
I use it when I have too though.
Ruby I use whenever I get the chance, and I really enjoy it!

Collapse
 
thedevtimeline profile image
Rashid

You could say that Python's dynamism is a design mistake from a performance perspective, because it makes it hard to make a straightforward efficient implementation, and it makes it hard (I didn't say completely impossible) to make an IDE with code completion, refactoring, and other nice things. At the same time, you could argue for the pros of dynamic languages.

Maybe one approach to start thinking about this is to look at the language changes from Python 2.x to 3.x. Some people would of course argue that print being a function is inconvenient, while others think it's an improvement. Overall, there are not that many changes, and most of them are quite small and subtle. For example, map() and filter() return iterators instead of lists, range() behaves like xrange() used to, and dict methods like dict.keys() return views instead of lists. Then there are some changes related to integers, and one of the big changes is binary/string data handling. It's now text and data, and text is always Unicode. There are several syntactic changes, but they are more about consistency than revamping the whole language.

From this perspective, it appears that Python has been pretty well designed on the language (syntax and sematics) level since at least 2.x. You can always argue about indentation-based block syntax, but we all know that doesn't lead anywhere :) So really I would say that Python's main design problems are in the performance domain – but these are basically the same challenges that any dynamic language has to face, and the Python family of languages and implementations are trying to address the issues.

Collapse
 
mongopark profile image
Ola' John Ajiboye

The thought that was going through my head while reading this. Ruby was why I fully committed to programming. I don't think Python matches the readability.