0% found this document useful (0 votes)
3 views

PYTHON (1)

Python is a high-level, interpreted programming language created by Guido Van Rossum, influenced by languages like C and ABC. It features simplicity, readability, and support for multiple programming paradigms, including object-oriented programming. Python is widely used in web development, data analysis, machine learning, and offers various job opportunities in the tech industry.

Uploaded by

jwalajjees
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

PYTHON (1)

Python is a high-level, interpreted programming language created by Guido Van Rossum, influenced by languages like C and ABC. It features simplicity, readability, and support for multiple programming paradigms, including object-oriented programming. Python is widely used in web development, data analysis, machine learning, and offers various job opportunities in the tech industry.

Uploaded by

jwalajjees
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

PYTHON

INTRODUCTION

 Python was developed by Guido Van Rossum.


 Python is derived from many other languages,
including C,C++, Unix shell and other scripting
languages.
 Python is a general-purpose interpreted, interactive,
object oriented and high level programming language.
FEATURES

E.g.: In C
• Simple and easy-to-learn #include<stdio.h>
#include<conio.h>
• Easy to read and void main()
{
understand printf(“Hello World”);
getch();
}
• Interpreted and interactive
In python
• Free and Open Source print(“Hello World”)

• Object-Oriented Language
• Portable

• Multi-Platform

• Graphical User Interface (GUI) Support

• Easy to Debug
PYTHON USED FOR
1. Web development
2. Machine learning
3. Data analysis/visualization
4. Web scrapping
5. Game development
6. Desktop app etc…
HISTORY

• The implementation of Python was started in the

December 1989 by Guido Van Rossum at CWI in

Netherland.

• In February 1991, van Rossum published the code


• Python is influenced by following programming languages:

ABC language

Modula-3

• Latest stable release 3.13.0 in Nov 2023


JOB OPPORTUNITIES

 Software Engineer
 Web Developer
 Data Analyst
 Data Scientist
 Software Developer
 Machine Learning Engineer
SITES
 Instagram
 YouTube
 Google
IDENTIFIERS

• An identifier in Python is a name used to identify a


variable, function, class, module, or any other object
 Rules for Identifiers in Python:

• Identifiers can be a combination of letters in lowercase(a


to z) or uppercase (A to Z) or digits (0 to 9) or an
underscore (_)
• Reserved keywords cannot be used as an identifier.
• Identifiers cannot begin with a digit.
• Special symbols like @, !, #, $, % etc. cannot be
used in an identifier.
• Identifier can be of any length.
• Identifiers are case-sensitive.
 Reserved Keywords
• Keywords are predefined and reserved words in Python that
have special meanings.
• They define the syntax of the code and cannot be used as
identifiers.
• There are 35 keywords in Python 3.11

• Examples of Python keywords include if, else, for, while, def,


True, False, import, pass and many more.
VARIABLES

• In Python, variables are containers that store specific values.

• Variables are reserved memory locations to store values.

• Each variable has a name and an associated value.

• We can store various types of data (numbers, strings, lists, etc.) in


variables.

• When we want to access the stored value, we simply refer to the


variable by its name.

• A variable is created the moment we assign a value to it.


 Rules for Python Variables:

• Variable names must start with a letter or the underscore


character.
• Variable name cannot start with a number.

• Variable name can only contain alpha-numeric characters


and underscores (A-z, 0-9, and _).
• Variable names are case-sensitive (e.g., Age and age are
different)
COMMENTS
• In Python, comments are essential for making code more
readable and for providing explanations.
 Single-Line Comments:

• To create a single-line comment, start the line with a #


symbol.
• Python will ignore everything after the #.

Eg: # This is a comment

print("Hello, World!")
 Inline Comments:

• You can also place comments at the end of a line of code.

• Python will ignore the rest of the line.

Eg: print("Hello, World!") # This is a comment


 Multiline Comments:

• Python doesn’t have a dedicated syntax for multiline


comments.
• Use multiple # symbols for each line:

Eg: # This is a comment

# written in

# more than just one line

print("Hello, World!")
• Alternatively, use a multiline string (triple quotes) to create
a comment block.

Eg: """
This is a comment written in
more than just one line
"""
print("Hello, World!")
QUOTES

• In Python, you can represent strings using a single quotes


(') or double quotes (") or triple quotes (“””)
 Single Quotes:

• Enclose a string within single quotes.

Eg: single_quoted = 'This is a single-quoted string.'


 Double Quotes:

• Enclose a string within double quotes.


Eg: double_quoted = "This is a double-quoted string.“

 Mixing Single and Double Quotes:

• Sometimes you need to include quotes within a string.

Eg: mixed_quotes2 = 'They said "We will miss you" as he left.'


 Triple Quotes (Multiline Strings):

• Python doesn’t have a dedicated syntax for multiline


comments

Eg: multiline_string = '''This is a multiline string.

It spans across multiple lines.'''


PYTHON OPERATORS

 In Python, operators are special symbols or keywords used to


perform various operations on variables and values.
 Arithmetic Operators
 Assignment Operators
 Comparison Operators
 Identity Operators
 Membership Operators
 Logical Operators
 Bit-wise Operators
CONDITIONAL STATEMENTS

 Conditional statements, allow you to execute different blocks of code based on certain
conditions.

 if statement

 if-else statement

 If-elif-else statement
if statement
The if statement is used to execute a block of code if a
specified condition is true. If the condition evaluates to false,
the block of code is skipped.

if condition :
# code to be executed
If-else statement
The if-else statement allows you to execute one block of code if
a condition is true, and a different block of code if the condition
is false.

if condition:
# code to be executed
else:
#code to be executed
If-elif-else Statement
The if-elif-else statement allows you to check multiple conditions and
execute different blocks of code based on which condition is true. The elif
keyword stands for "else if".

if expression 1:
# code to be executed
elif expression 2:
# code to be executed
elif expression 3:
# code to be executed
else:
# code to be executed
INDENTATION IN PYTHON

• Indentation is a crucial concept in Python.


• It determines the structure of your code by indicating
blocks of code that are executed together.
• In Python, indentation refers to the whitespace at the start
of a line. It is used to group statements together.
• Each block of code (such as loops, conditions, and
functions) is indented by a certain number of spaces or
tabs.
LOOPING STATEMENTS
 Looping statements in Python allow you to execute a block of code
repeatedly.
 It provides code re-usability.
 Using loops, we do not need to write the same code again and again.

• for loop
• while loop
for loop
for loops are used to iterate over a sequence of
items

for item in sequence:


# Code block to be repeated
While loop
while loops are used to repeatedly execute a block of statements while a
condition is true.

while condition:
# Code block to be repeated
Loop Control Statements
 ‘break’: Terminates the loop prematurely when a
certain condition is met.
 ‘continue’: Skips the current iteration of the loop
and proceeds to the next iteration.
 ‘pass’(placeholder): When the pass statement is
executed , nothing happens.
DATA TYPES
Immutable
• Integer
• Float
• Boolean
• String
• Tuple

Mutable
• List
• Set
• Dictionary
FUNCTIONS
 A group of related statements to perform a specific task is known as a
function.
 Functions help to break the program into smaller units.
 Functions avoid repetition and enhance code reusability.

Python provides two types of functions:-

i) Built-in functions
ii) User-defined functions
Built-in Functions:-
 These functions are provided by Python itself and are readily available for use
without the need for additional import statements.
 Examples include print(), len(), range(), max(), min(), etc.

print("Hello, world!")
User-defined Functions:-
 User-defined functions are created by the programmer to perform
specific tasks or operations.
def greet():

print("Hello, welcome!")

greet()
Defining Functions:-
 You can define a function in Python using the ‘def’ keyword followed by the function
name and parameters enclosed in parentheses. The function body is then indented.
Calling Functions:-
 To execute a function, simply write its name followed by parentheses.
Function Parameters:-
 Functions can accept parameters, which are values passed to the function when it's called.
Return Statement:-
 Functions can return values using the return statement.
Recursion:-
 A defined function can call itself.
Map Functions:-
 Works as an iterator to return a result after applying a function to
every item of an iterable.

map(function, iterables)
Filter Functions:-
 Used to filter elements from an iterable based on a
given condition.
filter(function, iterables)
Lambda Functions:-
 Lambda functions, also known as anonymous
functions.
 Its a small, unnamed functions that are defined using
the lambda keyword.
Function = lambda args:expression
OOPS CONCEPT
• Python is a multi-paradigm programming language.(approach to solve problems)
• Procedural Oriented Programming (POP)
• large programs are divided into smaller programs known as functions.
• no data security.
• Object Oriented Programming (OOP)
• Solve problem by using objects
• Object and class are the main components
Object Oriented Programming

 OOP is a programming paradigm that uses objects and classes.

 OOPs concepts focuses on re-usability of code.

 OOPs allow user to create their own objects, i.e, attributes and methods.

 Attribute : variable inside a class

 Methods : functions inside a class


Object-Oriented Concepts

1. Object
2. Class
3. Inheritance
4. Polymorphism
5. Abstraction
6. Encapsulation

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy