What is Python
- Python is a general-purpose, dynamic, high-level, and interpreted programming language. It supports Object Oriented programming approach to develop applications. It is simple and easy to learn and provides lots of high-level data structures.
- With its interpreted nature, Python's syntax and dynamic typing make it an ideal language for scripting and rapid application development.
- Python supports multiple programming patterns, including object-oriented, imperative, and functional or procedural programming styles.
- We don't need to use data types to declare variable because it is dynamically typed, so we can write a=10 to assign an integer value in an integer variable.
Features of Python Language
Python provides many useful features to the programmer. These features make it the most popular and widely used language. We have listed below few-essential features of Python.
- Easy to use and Learn: Python has a simple and easy-to-understand syntax, unlike traditional languages like C, C++, Java, etc., making it easy for beginners to learn.
- Interpreted Language: Python does not require compilation, allowing rapid development and testing. It uses Interpreter instead of Compiler.
- Object-Oriented Language: It supports object-oriented programming, making writing reusable and modular code easy.
- Open-Source Language: Python is open-source and free to use, distribute and modify.
- Extensible: Python can be extended with modules written in C, C++, or other languages.
- GUI Programming Support: Python provides several GUI frameworks, such as Tkinter and PyQt, allowing developers to create desktop applications easily.
- Integrated: Python can easily integrate with other languages and technologies, such as C/C++, Java, and . NET.
- Dynamic Memory Allocation: Python automatically manages memory allocation, making it easier for developers to write complex programs without worrying about memory management.
- Wide Range of Libraries and Frameworks: Python has a vast collection of libraries and frameworks, such as NumPy, Pandas, Django, and Flask, that can be used to solve a wide range of problems.
- Versatility: Python is a universal language in various domains such as web development, machine learning, data analysis, scientific computing, and more.
- Big Data and Machine Learning: Python has become the go-to language for big data and machine learning. Python has become popular among data scientists and machine learning engineers with libraries like NumPy, Pandas, Scikit-learn, TensorFlow, and more.
A variable is the name given to a memory location. In python variables need not be declared firs. They can be used directly. Variables in python are case-sensitive as most of the other programming languages.
num=10 # integer value assign to the variable num
m=10.5 # floating point value assign the the variable m.
str="Hello" # String value assign to the variable str
msg='Welcome'
Note - String value must be defined with either single quote or double quote
Python Operators
Operators are used to perform operations on variables and values.
Types of Operators
- Arithmetic operators
- Assignment operators
- Comparison operators
- Logical operators
- Identity operators
- Membership operators
- Bitwise operators
Arithmetic Operators
Arithmetic operators used between two operands for a particular operation. There are many arithmetic operators.
Addition (+): It is used to add two operands.For example, if a = 10, b = 10 then a+b = 20
Subtraction (-): It is used to subtract the second operand from the first operand. If the first operand is less than the second operand, the value results negative.
For example, if a = 20, b = 5 then a - b = 15
Divide (/): It is also know as float division. It returns the quotient after dividing the first operand by the second operand.
For example, if a = 20, b = 10 then a/b = 2.0
Floor division (//): It is also known as floor division. It provides the quotient's floor value, which is obtained by dividing the two operands.
For example
if a = 20, b = 10 then a//b = 2if a = 15, b = 4 then a//b = 3if a = 15.0, b = 3 then a//b=5.0if a = -5, b = 2 then a//b = -3
Multiplication (*): It is used to multiply one operand with the other.
For example, if a = 20, b = 4 then a * b = 80
Exponent (** ): As it calculates the first operand's power to the second operand, it is an exponent operator.
Reminder (%) It returns the reminder after dividing the first operand by the second operand.
For example, if a = 20, b = 10 => a%b = 0
0 Comments