Basics of Python

Divyansh JainDivyansh Jain
4 min read

What is Python?

Python is fast growing and a very easy to learn programming language. It is widely used in the fields of Development, Automation, DevOps, Machine Learning, AI, Big Data and many others. It is versatile in usage yet a very simple programming language to learn.

It offers a simple and readable syntax, making it beginner-friendly and efficient for rapid prototyping.

Python has a vast ecosystem of libraries and frameworks for tasks such as data analysis, machine learning, and web development. Python's integration capabilities and extensive community support make it an essential tool for computer engineers.

How to install Python?

Windows:

  • Go to Python's official website or Python Downloads

  • Select the latest version from the top or wanted a specific version scroll down to see more versions.

  • Run the package and follow the on-screen instructions.

  • Select the option to add Python to your system's PATH environment variable (if available) during the installation process.

  • Complete the installation by clicking "Install" or "Finish" (depending on the installer).

  • Open a command prompt or terminal window.

  • Type python or python3 in the command prompt and press Enter to verify the installation and check the Python version.

  • If the installation was successful, you should see the Python interpreter prompt, indicating that Python is installed and ready to use.

Linux

  • In Linux, we will install python3 using the command line.

  • Open the Terminal and update the system sudo apt update

  • Now install python3 with the following command sudo apt install python3, When Prompted enter Y to proceed.

  • In order to check if Python is properly installed use python3 --version

Data types in Python

There are various Data types in Python. Python is a dynamically typed programing language, Which means you don't have to define the type of the variable, variable can be created and assigned and the same time.

We can get the type of variables by type() function.

Different Datatypes are:

  • int - holds signed integers of non-limited length.

    i=100

  • float - holds floating precision numbers and it’s accurate up to 15 decimal places.

    f = 10.5

  • boolean - holds only True Or False.

    b = True

  • string - The string is a sequence of characters. Python supports Unicode characters. Generally, strings are represented by either single or double quotes.

    name="Divyansh"

  • list - Lists are just like arrays, declared in other languages which is an ordered collection of data. It is very flexible as the items in a list do not need to be of the same type. Lists are mutable.

    Lists in Python can be created by just placing the sequence inside the square brackets[].

    l = ["Divyansh", "Jain"]

  • dictionary - Python Dictionary is an unordered sequence of data of key-value pair form. It is similar to the hash table type. Dictionaries are written within curly braces in the form key: value. It is very useful to retrieve data in an optimized way among a large amount of data.

    d = {"name": "Divyansh", "surname": "Jain"}

  • range - Range is a built-in function to generate a sequence of integers with specified start, stop, and step values.

    r = range(100)

  • set - Set is an unordered collection of unique elements

    s ={'apple', 'banana', 'cherry'}

  • tuple - The tuple is another data type which is a sequence of data similar to a list. But it is immutable. That means data in a tuple is write-protected. Data in a tuple is written using parenthesis ( ) and commas

    t = ("Divyansh", "Jain")

Conclusion πŸŽ‰

This is the Basics of Python, Enough to get to started and start your journey with Python. You can do pretty much everything like scription automation and many more, you just need to get that hunger of happy learning within you. In coming days I'll be posting more in python. Stay Tuned!!

Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps πŸš€ by following me on Hashnode, LinkedIn (www.linkedin.com/in/Divyansh-Jain), and GitHub (https://github.com/Divyansh-jain).

Thank you for reading! πŸ™ Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.

2
Subscribe to my newsletter

Read articles from Divyansh Jain directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Divyansh Jain
Divyansh Jain

I'm a DevOps Engineer with over 3+ years of experience.