Python Basics
Python is a high-level programming language that is widely used for various purposes, including web development, data analysis, artificial intelligence, scientific computing, and more. It was created in the late 1980s by Guido van Rossum, and its design philosophy emphasizes code readability and simplicity.
Python is known for its concise syntax and ease of use, making it a popular language among beginners and experts alike. It supports various programming paradigms, including procedural, object-oriented, and functional programming.
Python has a vast standard library that provides many useful modules and functions for various tasks, such as web scraping, data processing, networking, and more. Additionally, Python has a vast ecosystem of third-party packages, including NumPy, Pandas, Scikit-learn, TensorFlow, and PyTorch, which make it a popular choice for data science and machine learning.
Python can be used on various platforms, including Windows, macOS, and Linux, and it has a vast community of developers who contribute to its development and provide support through various forums and communities.
Installation
To install Python on a Linux system, you can follow these general steps:
Open a terminal window on your Linux system.
Check if Python is already installed on your system by running the command:
python --version
If Python is already installed, you will see the version number printed to the console. If not, you can proceed with the installation.
Update the package list of your system by running the command:
sudo apt-get update
Install Python by running the command:
sudo apt-get install python
This command will install the latest version of Python available in your Linux distribution's repository.
Verify that Python has been installed correctly by running the command:
python --version
You should see the version number of Python printed to the console.
Different Data Types in Python
Python has several built-in data types that can be used to store and manipulate different kinds of data. Some of the most commonly used data types in Python are:
Integers: Integers are used to represent whole numbers. They can be positive, negative, or zero. For example:
5
,-10
,0
.Floating-point numbers: Floating-point numbers are used to represent decimal numbers. For example:
3.14
,2.5e-3
.Strings: Strings are used to represent a sequence of characters. They can be enclosed in single quotes ('...') or double quotes ("..."). For example:
'hello'
,"world"
.Booleans: Booleans are used to represent truth values. They can be either
True
orFalse
.Lists: Lists are used to represent a collection of ordered and mutable items. They can contain any combination of data types. For example:
[1, 'apple', True]
.Tuples: Tuples are used to represent an immutable collection of ordered items. They can contain any combination of data types. For example:
(1, 'apple', True)
.Dictionaries: Dictionaries are used to represent a collection of key-value pairs. They are unordered and mutable. For example:
{'name': 'John', 'age': 30}
.Sets: Sets are used to represent a collection of unique and unordered items. They can contain any combination of data types. For example:
{1, 'apple', True}
.
In addition to these built-in data types, Python also supports user-defined data types, such as classes and objects, which allow for more complex data structures and custom behavior.
Complete roadmap to learn Python:
Learn Basics
Basic Syntax
Variable and Data types
Conditionals
Type Casting, Exceptions
Functions, Builtin Functions
Lists, Tuple, Sets, Dictionaries
Data Structures and Algorithms
Array and Linked lists
Heaps, Stacks and Queues
Hash Tables
Binary search trees
Recursion
Sorting Algorithm
Advanced Topics
Iterators
RegEx
Decorators
Lambdas
OOP
Classes
Inheritance
Methods, Dunder
Modules
Builtin
Custom
Package Managers
PyPI
pip
Conda
List comprehensions
Generator Expressions
Paradigms
Learn Framework
Synchronous
Django
Flask
Pyramid
Asynchronous
gevent
aiohttp
Tornado
Sanic
Testing your apps
doctest
nose
pytest
unitest/ pyUnit
Reach me on:
Github-> https://github.com/Hrmn97
Twitter -> https://twitter.com/Harman9765
LinkedIn -> https://www.linkedin.com/in/chetan-harman-56310424a
Website -> https://devhrmn.netlify.app/