Python is an interpreted, high-level, dynamically typed, and general-purpose programming language.
Python is a platform-independent programming language. It means it can run easily on several platforms like Windows, Linux, Mac, and many more.
Table of Contents
Introduction to Python
Installing Python on different Operating System
Writing the first program in Python
How to write comments
Variables
Tokens
Conditional Statements
Data types in Python
Strings
Lists
Tuples
Sets
Dictionaries
Typecasting
Receiving Input
Looping Statements
Functions on Python
Lambda Functions
Classes and Objects
Inheritance
Abstraction
Modules
Regular Expressions
File Handling
Exceptions
Conclusion
Introduction to Python
Python is the most popular programming language for any beginner. It is easy to read and understand by any non-technical person.
It was created in 1990 by a Dutch programmer named Guido Van Rossum.
Python is an interpreted, high-level, dynamically typed, and general-purpose programming language.
Python is a platform-independent programming language. It means it can run easily on several platforms like Windows, Linux, Mac, and many more.
Features of Python
General Purpose: This language is used in various applications domains without being restricted to a particular domain.
Interpreted: It means it executes instructions directly, without previously compiling a program into machine-language instructions.
High Level: It uses natural language elements and automates crucial areas of computing such as memory allocation.
Dynamically Typed: Python is dynamically typed which means it identifies the type of the variable based on what kind of data you have allocated to the variable.
Object-oriented programming: Python supports OOP’s concept which means the concepts on objects, classes, and encapsulation help programs to run efficiently.
GUI Supported: It gives a visual look to our code which makes it more convenient and easy to understand by a normal human being
Applications of Python
Machine learning: Python can also be used to create various machine learning models and make predictions. There are libraries like Sklearn that will help us to do this task.
Web Applications: It is used to create various levels of web applications using web frameworks like Django and Flask. It is suitable for both backends as well as frontend development.
Automation: It can also be used to automate tasks like sending emails, filling forms, and scheduling your post on social media.
Game development: Python is also very popular in game development. There is a module called Pygame that helps to make amazing games.
Data Visualization: Python can also be used to visualize data. There are various libraries to do this like matplotlib, seaborn, and plotly.
Step 3- After the download is completed, double-click on the installer and then on the next screen check the box indicating to “Add Python 3.x to PATH” and then click on “Install Now”.
Step 4- After installation is complete, close this.
Step 6- Go to the command prompt and type “python — version ” in it. And you will see your python version it means you have successfully installed python.
Installing Python 3 on Mac
Step 1- First install brew. Go to https://brew.sh/ and follow the instructions on the first page to install it.
Step 2- Install python3 with brew
brew install python3
With this command, you have successfully installed Python on your system.
Installing Python 3 on Linux
Installing python3 using apt on the terminal.
sudo apt install python3
Writing the first program in Python
Let’s write the first “hello world” program in Python
print("hello world")
Comments can be used to make the code more descriptive and understand by a newbie programmer. So whenever any new tech guy comes and reads the code he will understand it clearly.
There are two types of comment
1- Single line comment: It is denoted by #.
# This is a single line comment
2- Multi-line comments: It is denoted by “””.
""" This is a comment written in more than just one line """
Variables
Variables are the placeholder that is used to represent data. To assign values to a variable we use assignment operator.