Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 18
PYTHON
All you need to know about PYTHON
By: SHANVI KOTHAPALLI WHAT IS PYTHON? Python is a high-level, interpreted, text-based programming language known for its simplicity, readability, and versatility. It was created by Guido van Rossum and first released in 1991. It runs on IDLE. Here are some key features and uses of Python:
1.Readability: Python syntax is designed to be clear and straightforward, making it
easy to learn and write. 2.Interpreted Language: Python code is executed line by line, which makes debugging easier and speeds up development. 3.Dynamically Typed: Variables in Python do not need explicit declaration to reserve memory space, making it more flexible and easier to use. 4.Cross-Platform: Python runs on various platforms, including Windows, macOS, Linux, and many others. WHERE IS PYTHON USED? Python is used for… • Web Development: Frameworks like Django and Flask make web development efficient and scalable. • Data Science and Machine Learning: Libraries such as NumPy and TensorFlow are widely used for data analysis and machine learning. • Automation and Scripting: Python is often used for writing scripts to automate repetitive tasks. • Software Development: Python is used in various stages of software development, from prototyping to production. • Game Development: Libraries like Pygame are used for creating simple games. • Networking: Python provides libraries for handling network communications and creating networked applications. VARIABLES IN PYTHON • In Python, variables are used to store data that can be referenced and manipulated in a program. Here are the basics of Python variables: 1. Variable Declaration and Assignment • In Python, you don't need to declare a variable before assigning a value to it. You just assign a value to a variable name using the = operator. VARIABLES IN PYTHON • 2. Variable Naming Rules • A variable name must start with a letter or the underscore character. • A variable name cannot start with a number. • A variable name can only contain alphanumeric characters and underscores (A-z, 0-9, and _). • Variable names are case-sensitive (age, Age, and AGE are three different variables). VARIABLES IN PYTHON • 3. Dynamic Typing • Python is dynamically typed, meaning you can change the type of a variable after it has been set once the code has been written VARIABLES IN PYTHON • 4. Data Types • Variables can hold values of different data types. Some common data types include: • Integers: Whole numbers. • Floats: Decimal numbers. • Strings: Text. • Booleans: True or False values. • Lists: Ordered collections of items. • Tuples: Ordered, immutable collections of items.) • Dictionaries: Unordered collections of key-value pairs. OPERATORS IN PYTHON • In Python, operators are special symbols or keywords that are used to perform operations on variables and values. Arithmetic Operators • Arithmetic operators are used to perform mathematical operations. • Addition (+): Adds two operands. • Subtraction (-): Subtracts the second operand from the first. • Multiplication (*): Multiplies two operands. • Division (/): Divides the first operand by the second. • Floor Division (//): Divides the first operand by the second and returns the largest whole number smaller or equal to the result. • Modulus (%): Returns the remainder when the first operand is divided by the second. OPERATORS IN PYTHON • 2. Comparison Operators • Comparison operators are used to compare two values and return a Boolean result (True or False). • Equal to (==): Returns True if the operands are equal. • Not equal to (!=): Returns True if the operands are not equal. OPERATORS IN PYTHON • Greater than (>): Returns True if the first operand is greater than the second. • Less than (<): Returns True if the first operand is less than the second. • Greater than or equal to (>=): Returns True if the first operand is greater than or equal to the second. • Less than or equal to (<=): Returns True if the first operand is less than or equal to the second. OPERATORS IN PYTHON • 3. Logical Operators • Logical operators are used to combine conditional statements. • Logical AND (and): Returns True if both operands are True. • Logical OR (or): Returns True if at least one of the operands is True. • Logical NOT (not): Reverses the result of the operand. OPERATORS IN PYTHON • 4. Assignment Operators • Assign (=): Assigns the right-hand side value to the left-hand side variable. • Add and assign (+=): Adds the right-hand side value to the left-hand side variable and assigns the result to the variable. • Subtract and assign (-=): Subtracts the right-hand side value from the left- hand side variable and assigns the result to the variable. • Multiply and assign (*=): Multiplies the left-hand side variable by the right-hand side value and assigns the result to the variable. OPERATORS IN PYTHON • Divide and assign (/=): Divides the left-hand side variable by the right- hand side value and assigns the result to the variable. • Floor divide and assign (//=): Floor divides the left-hand side variable by the right-hand side value and assigns the result to the variable. • Modulus and assign (%=): Applies modulus operation between the left- hand side variable and the right-hand side value and assigns the result to the variable. • Exponentiate and assign (**=): Raises the left-hand side variable to the power of the right-hand side value and assigns the result to the variable OPERATORS IN PYTHON • 5. Bitwise Operators • Bitwise operators are used to perform bit-level operations on integers. • Bitwise AND (&): Performs bitwise AND operation. • Bitwise OR (|): Performs bitwise OR operation. • Bitwise XOR (^): Performs bitwise XOR operation. • Bitwise NOT (~): Performs bitwise NOT operation. OPERATORS IN PYTHON • Membership operators are used to test if a sequence contains an element. • In (in): Returns True if the value is found in the sequence. • Not In (not in): Returns True if the value is not found in the sequence. OPERATORS IN PYTHON • 7. Identity Operators • Identity operators are used to compare the memory locations of two objects. • Is (is): Returns True if the two variables point to the same object. • Is Not (is not): Returns True if the two variables do not point to the same object. COMMENTS IN PYTHON • In Python, comments are used to explain code and make it more readable. They are ignored by the Python interpreter during execution. There are two types of comments in Python: single-line comments(#) and multi-line comments(//).