What is Python?
Python is a computer language used in various applications It was introduced by Guido van Rossum and is an open-source high-level and object-oriented language
Python consists of vast libraries and frameworks like Django, Flask, TensorFlow, PyTorch, Pandas, etc.
How to install Python
For Windows:
Click here to download Python on the Windows operating system
For Linux:
Open Terminal and type the below command to install the python
sudo apt-get update
sudo apt install python3
Task1:
Install Python in your respective OS, and check the version.
python3 --version
Read about different Data Types in Python.
Numeric Types:
int: Represents integers, such as 1, -5, or 1000.
float: Represents floating-point numbers, which are numbers with a decimal point, like 3.14 or -0.5.
complex: Represents complex numbers in the form
a + bj
, wherea
andb
are floats, andj
represents the square root of -1 (e.g.,3 + 2j
).
Sequence Types:
str: Represents strings of characters, like "Hello, World!" or 'Python'.
list: Represents ordered, mutable (changeable) sequences of objects. Lists are created using square brackets, e.g.,
[1, 2, 3]
.tuple: Represents ordered, immutable (unchangeable) sequences of objects. Tuples are created using parentheses, e.g.,
(1, 2, 3)
.
Mapping Type:
- dict: Represents a dictionary, which is an unordered collection of key-value pairs. Dictionaries are created using curly braces with key-value pairs, e.g.,
{'name': 'Alice', 'age': 30}
.
- dict: Represents a dictionary, which is an unordered collection of key-value pairs. Dictionaries are created using curly braces with key-value pairs, e.g.,
Set Types:
set: Represents an unordered collection of unique elements. Sets are created using curly braces or the
set()
constructor, e.g.,{1, 2, 3}
orset([1, 2, 2, 3])
.frozenset: Similar to a set but is immutable. Once created, you cannot modify its contents.
Boolean Type:
- bool: Represents a Boolean value, which can be either
True
orFalse
. It's often used for conditional statements and logical operations.
- bool: Represents a Boolean value, which can be either
None Type:
- None: Represents the absence of a value. It is often used to indicate the absence of a return value in functions or methods.
Binary Types:
bytes: Represents a sequence of bytes, similar to a string but immutable. It's often used for working with binary data.
bytearray: Similar to bytes but mutable.
Iterator Types:
iterable: Represents any object capable of returning its elements one at a time. Common iterable types include lists, tuples, dictionaries, and strings.
iterator: Represents an object that implements the iterator protocol, allowing you to loop over its elements using a
for
loop or thenext()
function.
Custom Classes:
- Python also allows you to define your own custom data types using classes. You can create objects with attributes and methods to represent complex data structures.
Explore this videos playlist to know more about python
Thank You readers for going through my blog if you love it don't forget to give likes for more such content follow me