SlideShare a Scribd company logo
Sanjivani Rural Education Society's
Sanjivani College of Engineering, Kopargaon 423603.
-Department of Strucutral Engineering-
By
Mr. Sumit S. Kolapkar (Assistant Professor)
Mail Id- kolapkarsumitst@sanjivani.org.in
Ø What is Language?-
The method of human communication, either spoken or
written, consisting of the use of words in a structured
and conventional way.
Ø What is Computer Language?-
A code or syntax which is used to write programs or any
specific applications. Categories-
Machine Language-
Ø Oldest one
Ø Input is binary input processed by machine (binary
input is in ‘1’ and ‘0’ form)
Ø System needs a compiler and interpreter to convert
the language into computer language so that it can be
processed by a machine.
Machine Language-
Ø Can be directly understood by a central processing
unit (CPU)
Ø The operating system of the computer system is used
to identify the exact machine language used for that
particular system
Ø The operating system defines how the program
should be write so that it can be converted to machine
language and the system takes appropriate action.
Ø The computer programs and scripts can also be
written in other programming languages like C, C++,
and JAVA etc.
Ø However, these languages cannot be directly
understood by a computer system so there is a need
for a program that can convert these computer
programs to machine language.
Machine Language-
Ø The compiler is used to convert the programs to
machine language which can be easily understood by
computer systems.
Ø The compiler generates the binary file and executable
file
Ø Example of machine language for the text “Hello
World”-
01001000 0110101 01101100 01101100 01101111
00100000 01010111 01101111 01110010 01101100
01100100
Assembly Language-
Ø A low-level language for microprocessors and many
other programmable devices
Ø Considered as a second-generation language
Ø Mostly famous for writing an operating system and in
writing different desktop applications.
Ø Is considered as a group of other languages
Ø For any processor, the most used programming
language is assembly language.
High Level Language-
Ø The development of higher-level language is done for
a programmer to write a human-readable program
that can be easily understood by any user.
Ø The syntax used and the programming style can be
easily understood by humans if it is compared to low-
level language.
Ø The only requirement in a high-level language is the
need for a compiler.
Ø Before the execution of high-level programs, it needs
to be converted to machine-level language.
Ø Examples are C++, C, JAVA, FORTRAN, Pascal, Perl,
Ruby, and Visual Basic.
Ø Why Should Learn To Write a Program?-
Ø It helps in speeding up the input and output processes
in a machine.
Ø It is important to automate, collect, manage, calculate,
and analyze the processing of data and information
accurately.
Ø Programming helps to create software and
applications that help computer and mobile users in
daily life.
Ø What is Program?-
Ø A computer program consists of code that is executed
on a computer to perform particular tasks
Ø Programming is the process of giving machines a set
of instructions that describe how a program should be
carried out
Ø Programmers will start by using a code editor or IDE to
write what is called source code
Ø Source code needs to be converted into machine
language so machines can understand the instructions
and execute the program. This process of converting
source code into machine language is known as
compiling
Ø Examples of compiled programming languages would
be C and C++
Ø What is Program?-
Ø There are other languages that do not use compilers.
Instead, these languages will use an interpreter that
will read and execute the code
Ø Examples of interpreted programming languages
would be JavaScript and PHP
Ø The building block of a Program?-
A block is a piece of Python program text that is
executed as a unit.
Ø input
Get data from the “outside world”. This might be reading
data from a file, or even some kind of sensor like a
microphone or GPS. In our initial programs, our input will
come from the user typing data on the keyboard.
Ø output
Display the results of the program on a screen or store
them in a file or perhaps write them to a device like a
speaker to play music or speak text.
Ø The building block of a Program?-
Ø sequential execution
Perform statements one after another in the order they
are encountered in the script.
conditional execution
Check for certain conditions and then execute or skip a
sequence of statements.
Ø repeated execution
Perform some set of statements repeatedly, usually with
some variation.
Ø reuse
Write a set of instructions once and give them a name
and then reuse those instructions as needed throughout
your program.
Ø Computer Hardware Architecture-
The Central Processing Unit (or CPU): Is that part of the
computer that is built to be obsessed with “what is next?”
It executes instructions comprising a computer
program.It performs basic arithmetic, logic, controlling,
and input/output (I/O) operations specified by the
instructions in the program.
Ø Computer Hardware Architecture-
The Main Memory: Is used to store information that the
CPU needs in a hurry. The main memory is nearly as
fast as the CPU. But the information stored in the main
memory vanishes when the computer is turned off.
Ø Computer Hardware Architecture-
The Secondary Memory: Is also used to store
information, but it is much slower than the main memory.
The advantage of the secondary memory is that it can
store information even when there is no power to the
computer. Examples of secondary memory are disk
drives or flash memory (typically found in USB sticks and
portable music players).
Ø Computer Hardware Architecture-
The Input and Output Devices are simply our screen,
keyboard, mouse, microphone, speaker, touchpad, etc.
They are all of the ways we interact with the computer.
Ø What is Python?-
Python is a high-level, general-purpose, self-contained
programming language designed to meet the needs of
computer scientists, software developers, and college
students interested in coding
Ø History of Python-
Is released first in the late 1991 by Guido van Rossum
as 0.9.0
Python 2.0 released on 16 October 2000
Python 3.0, released on 03 December 2008
Ø Features of Python?-
Ø Python is very easy to start programming with and
because of flexible syntax, it can be used to almost
any kind of software application.
Ø Is an open source language that’s free to use.
Ø Interpreted Language
Ø Dynamically Typed Language
Ø Large Standard Library
Ø High-Level Language
Ø Large Community Support
Ø Platform Independent
Ø Extensible and Embeddable
Ø Graphical User Interface (GUI) Support
Ø Features of Python?-
Ø Features of Python?-
Ø Reserved Keywords in Python-
Ø It has very special meaning to Python
Ø They have one and only one meaning to Python
Ø Writing meaningful own words that has meaning to us
is called Variables
Ø Has liberty to use any word as a variable but can not
use any Python’s reserved words name as a variable
Ø So the reserved words are those words in the
language where humans talk to Python
Ø Reserved Keywords in Python-
Ø Values andTypes-
A value is one of the basic things a program works with,
like a letter or a number. Ex: 1, 2, or 5.4, or “Hello World!”
Note-
Ø 1, 2 is an integer whereas “Hello World!” is a string.
(strings of letter).
Ø Human being and interpreter can identify strings
easily beacause it is enclosed in a Quotation Marks
Ø 5.4 is the floating point
Types:
Integer (int):-
Is that which does not have any fractional part. The print
statement also works for integers. Contains negative and
positive whole numbers Ex:
>>>print(4)
4
Ø Values andTypes-
Types:
Floating-point:-
Is that which have a fractional part. The print statement
also works for floating point. Ex:
>>>print(4.5)
4.5
OR
>>>print(1.5*4)
6
Ø Values andTypes-
Types:
Complex Numbers with Imaginary parts:-
Is conists of a real part and an imaginary part. Ex:
Ø Values andTypes-
Type of Value by an Interpreter:
>>> type('Hello, World!')
<class 'str'>
>>> type(17)
<class 'int'>
>>> type(3.2)
<class 'float'>
Note-
What about values like “17” and “3.2”?
>>> type('17')
<class 'str'>
>>> type('3.2')
<class 'str'>
Ø Values andTypes-
Type of Value by an Interpreter:
>>> print(1,000,000)
1 0 0
Ø Python interprets 1,000,000 as a comma separated
sequence of integers, which it prints with spaces
between.
Ø Is known as a semantic error.
Ø The code runs without producing an error message,
but it doesn’t do the “right” thing.
Ø Variables-
Ø A variable is a name given to a memory location, that
holds or refers to a value.
Ø It can contain both letters and numbers, but it cannot
start with a number
Ø If we give a variable an illegal name, we will get a
syntax error:
>>> 76trombones = 'big parade'
SyntaxError: invalid syntax
>>> more@ = 1000000
SyntaxError: invalid syntax
>>> class = 'Advanced Theoretical Zymurgy'
SyntaxError: invalid syntax
Ø Variables-
• 76trombones is illegal because it begins with a
number
• more@ is illegal because it contains an illegal
character, @
• What went wrong with class as a variable.
It turns out that class is one of Python’s keywords
Ø Character Set-
Ø It is a valid set of all the valid characters/symbols
which can be recognized by the compiler/interpreter
Ø Alphabets- “a to z” OR “A to Z”
Ø Symbols-
Ø Numbers- “0 to 9”
Ø Whitespaces- Blank space, tabs, enter, line feed
(Newline),
Ex-
>>>print(“Hello@123”)
Ø Lexical structure-
Is the set of basic rules that govern how you write
programs in that language.
Ø Tokens (Lexical Units) in Python-
Ø Each logical line (statement) in Python is broken
down into a series of lexical components known as
tokens.
Ø Python converts characters into tokens.
Ø Each token corresponds to a substring of the logical
line.
Note-
• Tokens are the smallest and basic fraction in Python
program.
• Is a set of one or more characters having a meaning
together.
Ø Statements-
Ø A statement is a unit of code (tokens) that the Python
interpreter can execute.
Ø In simple terms, statements are the things you write
to tell Python what your programs should do.
Ø By combining statements, you specify a procedure
that Python performs to satisfy a program’s goals.
Ø Python program structure-
1. Programs are composed of modules.
2. Modules contain statements.
3. Statements contain expressions.
4. Expressions create and process objects.
Ø Types of Tokens-
i. Identifiers,
ii. Keywords,
iii. Operators,
iv. Delimiters, and
v. Literals/Values/Data
Identifiers:-
Is a name used to identify a variable, function, class,
module, or other object.
It aids in distinguishing one entity from others.
Ø Types of Tokens-
Characteristics of Python Identifiers:-
• The initial letter of the identifier should be any letter (A
to Z or a to z) or underscore (_).
• Upper and lower case letters have distinct
characteristics.
• Except for the initial letter, any digit from 0 to 9 can
be part of the identification.
• It shouldn’t be used as a keyword
• Except for the underscore (_), an identifier cannot
contain any special characters such as @, $, and %.
• Identifiers can be as long as you want them to be.
• Case matters when it comes to identifier names.
Myself and myself, for example, are not the same
thing.
Ø Types of Tokens-
Operators:-
Ø Is a special symbol when applied to the variables and
other objects in an expression, cause a computation
or action to occur. There are 7 different operators.
i)Arithmetic Operators-
It performs all the mathematical calculations.
Ex- (+, -, /, *, %,//)
Ø Types of Tokens-
Operators:-
ii) Relational Operator/Comparative Operator-
Examines the relationship between two operands.
Note-
i. Are always in binary form
ii. Results are always in Boolean form (i.e True or
False)
Ø Types of Tokens-
Operators:-
ii) Relational Operator/Comparative Operator-
Ø Types of Tokens-
Operators:-
iii) Assignment Operators-
Employed to allocate a value to a variable. Ex-
• (+=)It adds the right side input to the left side input
and then assigns the result to the left side input.
• (-= )Augmented assignment operator- It takes the
right side operand and subtracts it from the left side
operand, then assigns the result to the left side
operand.
Note-
i. Are always in binary form
ii. Use ‘=’ sign to assign it
iii. Have two values ‘Right-value’ and ‘Left-value’; Right-value
evaluate first then get assign to Left-value
Ø Types of Tokens-
Operators:-
iii) Assignment Operators-
Ø Types of Tokens-
Operators:-
iv) Logical Operators-
Compares the two boolean expressions and yield a
boolean result. Ex-
• The logical and operator makes a condition true if
both operands are true or non-zero.
• The logical or operator returns true if one of the two
operands is true or non-zero.
Note-
i. May be Unary or Binary
ii. Unary logical operator is not and Binary logical
operator is and and or
Ø Types of Tokens-
Operators:-
iv) Logical Operators-
Ø Types of Tokens-
Operators:-
v) Bitwise Operators-
It manipulates individual bits in one or more bit patterns
or binary numbers.
For example, If a binary XOR operator (^) is set in one
input value but not both, it copies the matching binary 1
to the result.
Note-
i. May be Unary or Binary
ii. Unary bitwise operator is only one i.e first
complement (~) and Binary bitwise operator is and
(&), or (|), xor (^), right shift (>>), left shift (<<)
iii. Bitwise operator does not work with string and
floating point.
Ø Types of Tokens-
Operators:-
v) Bitwise Operators-
Ø Types of Tokens-
Operators:-
vi) Membership Operators-
It checks for membership in successions, such as a
string, list, or tuple.
It fetches a variable and if the variable is found in the
supplied sequence, evaluate to true; otherwise, evaluate
to false.
Note-
i. Relational/comparative/arithmetic operators are used
to check values only whereas identity operator (in
and not in) compares “Id” only not a value.
ii. Results are always in Boolean form
iii. Ex:>>>print(2 in [1,2,3,4,5,6])→True
>>>print(2 in [1,3,4,5,6])→False
Ø Types of Tokens-
Operators:-
vi) Membership Operators-
Ø Types of Tokens-
Operators:-
vii) Identity Operators-
When comparing the memory locations of two objects,
identity operators are used. If two variables point to
separate objects, it does not return true; otherwise, it
returns false.
Note-
i. Is a special feature of Python not available in other
languages like C, C++, Java etc.
ii. Relational/comparative/arithmetic operators are used
to check values only whereas identity operator (is
and not is) compares “Id” only not a value.
iii. Results are always in Boolean form
Ø Types of Tokens-
Operators:-
vii) Identity Operators-
Ø Types of Tokens-
Literals:-
• Literals, in Python are the data elements (numeric or
non-numeric) with a fixed value to be store in
variable.
Types of Literals-
i. String Literals (Text Constants)
ii. Numeric Literals. These are further of three types,
integer, float, and complex literals.
iii. Boolean Literals
iv. Literal Collection
Note-
Lists, tuples, dictionaries, and sets are all examples of
literal collections in Python.
Ø Types of Tokens-
Punctuators OR Separators:-
• Punctuators are tokens in python employed to put the
grammar and structure of syntax into practice.
• Punctuators are symbols that are used to structure
programming sentences in a computer language.
• Ex- ‘, ‘ ,#,  ,( ) ,{ },[ ] ,@ ,: , =
Ø Operands-
The values that an operator acts on are called operands.
Ø Expression-
A sequence of operands and operators is called an
expression
Ø Difference between Expression and
Statement-
Expression-
An expression is a combination of values(Constants),
variables and operators.
An expression may also include call to functions and
objects.
Any expression evaluates to a single value, which
becomes the value of the expression.
Ex:-
a = 10 # This is an assignment statement
b = 10 # This is an assignment statement
print(a + b) # a + b is an expression and print(a + b) is a
statement
Ø Difference between Expression and
Statement-
Statements-
A statement in Python is a logical instruction which can
be read and executed by Python interpreter. Types are-
i. Print statements
ii. Assignment statements
iii. Selective statements
iv. Iterative statements
v. Function declaration statements
Ø Order of operations in Python-
• When more than one operator appears in an
expression, the order of evaluation depends on the
rules of precedence
• The acronym PEMDAS is a useful way to remember
the rules:
Ø Parentheses have the highest precedence.
Ø Expressions in parentheses are evaluated first, 2 * (3-
1) is 4, and (1+1)**(5-2) is 8.
Ø Even we can use parentheses to make an expression
easier to read, as in (minute * 100) /60, even if it
doesn’t change the result.
Ø Exponentiation has the next highest precedence, so
2**1+1 is 3, not 4, and 3*1**3 is 3, not 27.
Ø Order of operations in Python-
Ø Multiplication and Division have the same precedence,
which is higher than Addition and Subtraction, which
also have the same precedence. So 2*3-1 is 5, not 4,
and 6+4/2 is 8, not 5.
Ø Operators with the same precedence are evaluated
from left to right. So the expression 5-3-1 is 1, not 3,
because the 5-3 happens first and then 1 is
subtracted from 2.
Note-
When in doubt, always put parentheses in your
expressions to make sure the computations are
performed in the order you intend.
Ø Order of operations in Python-
Example:- (43+13−9/3∗ 7)
i. From left to right, 9/3∗ 7= 3∗ 7= 21
ii. Expression has become, 43+13−21
iii. Left to right Associativiy rule will be followed again.
So, the final value of expression will be-
43+13−21 = 56−21= 35
THANK YOU....
Ad

More Related Content

Recently uploaded (20)

800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx
54mdaadil
 
VISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated detailsVISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated details
Vishal Kumar Singh
 
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
Guru Nanak Technical Institutions
 
EHSS Orientation 2023 - Copy.Orientation
EHSS Orientation 2023 - Copy.OrientationEHSS Orientation 2023 - Copy.Orientation
EHSS Orientation 2023 - Copy.Orientation
GulfamShahzad11
 
4 Renewable-Energy-Chemistry-ppt-PP.pptx
4 Renewable-Energy-Chemistry-ppt-PP.pptx4 Renewable-Energy-Chemistry-ppt-PP.pptx
4 Renewable-Energy-Chemistry-ppt-PP.pptx
maairapayongayong
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
Comprehensive Guide to Distribution Line Design
Comprehensive Guide to Distribution Line DesignComprehensive Guide to Distribution Line Design
Comprehensive Guide to Distribution Line Design
Radharaman48
 
Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)
efs14135
 
Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...
Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...
Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...
balbaliadam1980
 
PYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptxPYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptx
rmvigram
 
introduction to Rapid Tooling and Additive Manufacturing Applications
introduction to Rapid Tooling and Additive Manufacturing Applicationsintroduction to Rapid Tooling and Additive Manufacturing Applications
introduction to Rapid Tooling and Additive Manufacturing Applications
vijimech408
 
Tech innovations management entreprenuer
Tech innovations management entreprenuerTech innovations management entreprenuer
Tech innovations management entreprenuer
Subramanyambharathis
 
digital computing plotform synopsis.pptx
digital computing plotform synopsis.pptxdigital computing plotform synopsis.pptx
digital computing plotform synopsis.pptx
ssuser2b4c6e1
 
Relationship of inheritance in oopm.pptx
Relationship of inheritance in oopm.pptxRelationship of inheritance in oopm.pptx
Relationship of inheritance in oopm.pptx
ayush626953
 
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
 
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks Conferences
 
Full_Cybersecurity_Project_Report_30_Pages.pdf
Full_Cybersecurity_Project_Report_30_Pages.pdfFull_Cybersecurity_Project_Report_30_Pages.pdf
Full_Cybersecurity_Project_Report_30_Pages.pdf
Arun446808
 
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
Journal of Soft Computing in Civil Engineering
 
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
ssuserd9338b
 
SOC2_Tools_and_Goals SOC 2 Type 2 Checklist
SOC2_Tools_and_Goals SOC 2 Type 2 ChecklistSOC2_Tools_and_Goals SOC 2 Type 2 Checklist
SOC2_Tools_and_Goals SOC 2 Type 2 Checklist
9905234521
 
800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx800483270-Food-Delivery-MERN-Stack-Presentation.pptx
800483270-Food-Delivery-MERN-Stack-Presentation.pptx
54mdaadil
 
VISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated detailsVISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated details
Vishal Kumar Singh
 
EHSS Orientation 2023 - Copy.Orientation
EHSS Orientation 2023 - Copy.OrientationEHSS Orientation 2023 - Copy.Orientation
EHSS Orientation 2023 - Copy.Orientation
GulfamShahzad11
 
4 Renewable-Energy-Chemistry-ppt-PP.pptx
4 Renewable-Energy-Chemistry-ppt-PP.pptx4 Renewable-Energy-Chemistry-ppt-PP.pptx
4 Renewable-Energy-Chemistry-ppt-PP.pptx
maairapayongayong
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
Comprehensive Guide to Distribution Line Design
Comprehensive Guide to Distribution Line DesignComprehensive Guide to Distribution Line Design
Comprehensive Guide to Distribution Line Design
Radharaman48
 
Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)Domain1_Security_Principles --(My_Notes)
Domain1_Security_Principles --(My_Notes)
efs14135
 
Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...
Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...
Learning Spark- Lightning-Fast Big Data Analysis -- Holden Karau, Andy Konwin...
balbaliadam1980
 
PYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptxPYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptx
rmvigram
 
introduction to Rapid Tooling and Additive Manufacturing Applications
introduction to Rapid Tooling and Additive Manufacturing Applicationsintroduction to Rapid Tooling and Additive Manufacturing Applications
introduction to Rapid Tooling and Additive Manufacturing Applications
vijimech408
 
Tech innovations management entreprenuer
Tech innovations management entreprenuerTech innovations management entreprenuer
Tech innovations management entreprenuer
Subramanyambharathis
 
digital computing plotform synopsis.pptx
digital computing plotform synopsis.pptxdigital computing plotform synopsis.pptx
digital computing plotform synopsis.pptx
ssuser2b4c6e1
 
Relationship of inheritance in oopm.pptx
Relationship of inheritance in oopm.pptxRelationship of inheritance in oopm.pptx
Relationship of inheritance in oopm.pptx
ayush626953
 
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
 
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks #4. Have you been listening ? Because we have !
ResearchTalks Conferences
 
Full_Cybersecurity_Project_Report_30_Pages.pdf
Full_Cybersecurity_Project_Report_30_Pages.pdfFull_Cybersecurity_Project_Report_30_Pages.pdf
Full_Cybersecurity_Project_Report_30_Pages.pdf
Arun446808
 
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
ssuserd9338b
 
SOC2_Tools_and_Goals SOC 2 Type 2 Checklist
SOC2_Tools_and_Goals SOC 2 Type 2 ChecklistSOC2_Tools_and_Goals SOC 2 Type 2 Checklist
SOC2_Tools_and_Goals SOC 2 Type 2 Checklist
9905234521
 

Featured (20)

2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design ProcessStorytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design ProcessStorytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
Ad

Introduction to Python and its basics.pdf

  • 1. Sanjivani Rural Education Society's Sanjivani College of Engineering, Kopargaon 423603. -Department of Strucutral Engineering- By Mr. Sumit S. Kolapkar (Assistant Professor) Mail Id- kolapkarsumitst@sanjivani.org.in
  • 2. Ø What is Language?- The method of human communication, either spoken or written, consisting of the use of words in a structured and conventional way. Ø What is Computer Language?- A code or syntax which is used to write programs or any specific applications. Categories- Machine Language- Ø Oldest one Ø Input is binary input processed by machine (binary input is in ‘1’ and ‘0’ form) Ø System needs a compiler and interpreter to convert the language into computer language so that it can be processed by a machine.
  • 3. Machine Language- Ø Can be directly understood by a central processing unit (CPU) Ø The operating system of the computer system is used to identify the exact machine language used for that particular system Ø The operating system defines how the program should be write so that it can be converted to machine language and the system takes appropriate action. Ø The computer programs and scripts can also be written in other programming languages like C, C++, and JAVA etc. Ø However, these languages cannot be directly understood by a computer system so there is a need for a program that can convert these computer programs to machine language.
  • 4. Machine Language- Ø The compiler is used to convert the programs to machine language which can be easily understood by computer systems. Ø The compiler generates the binary file and executable file Ø Example of machine language for the text “Hello World”- 01001000 0110101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100
  • 5. Assembly Language- Ø A low-level language for microprocessors and many other programmable devices Ø Considered as a second-generation language Ø Mostly famous for writing an operating system and in writing different desktop applications. Ø Is considered as a group of other languages Ø For any processor, the most used programming language is assembly language.
  • 6. High Level Language- Ø The development of higher-level language is done for a programmer to write a human-readable program that can be easily understood by any user. Ø The syntax used and the programming style can be easily understood by humans if it is compared to low- level language. Ø The only requirement in a high-level language is the need for a compiler. Ø Before the execution of high-level programs, it needs to be converted to machine-level language. Ø Examples are C++, C, JAVA, FORTRAN, Pascal, Perl, Ruby, and Visual Basic.
  • 7. Ø Why Should Learn To Write a Program?- Ø It helps in speeding up the input and output processes in a machine. Ø It is important to automate, collect, manage, calculate, and analyze the processing of data and information accurately. Ø Programming helps to create software and applications that help computer and mobile users in daily life.
  • 8. Ø What is Program?- Ø A computer program consists of code that is executed on a computer to perform particular tasks Ø Programming is the process of giving machines a set of instructions that describe how a program should be carried out Ø Programmers will start by using a code editor or IDE to write what is called source code Ø Source code needs to be converted into machine language so machines can understand the instructions and execute the program. This process of converting source code into machine language is known as compiling Ø Examples of compiled programming languages would be C and C++
  • 9. Ø What is Program?- Ø There are other languages that do not use compilers. Instead, these languages will use an interpreter that will read and execute the code Ø Examples of interpreted programming languages would be JavaScript and PHP
  • 10. Ø The building block of a Program?- A block is a piece of Python program text that is executed as a unit. Ø input Get data from the “outside world”. This might be reading data from a file, or even some kind of sensor like a microphone or GPS. In our initial programs, our input will come from the user typing data on the keyboard. Ø output Display the results of the program on a screen or store them in a file or perhaps write them to a device like a speaker to play music or speak text.
  • 11. Ø The building block of a Program?- Ø sequential execution Perform statements one after another in the order they are encountered in the script. conditional execution Check for certain conditions and then execute or skip a sequence of statements. Ø repeated execution Perform some set of statements repeatedly, usually with some variation. Ø reuse Write a set of instructions once and give them a name and then reuse those instructions as needed throughout your program.
  • 12. Ø Computer Hardware Architecture- The Central Processing Unit (or CPU): Is that part of the computer that is built to be obsessed with “what is next?” It executes instructions comprising a computer program.It performs basic arithmetic, logic, controlling, and input/output (I/O) operations specified by the instructions in the program.
  • 13. Ø Computer Hardware Architecture- The Main Memory: Is used to store information that the CPU needs in a hurry. The main memory is nearly as fast as the CPU. But the information stored in the main memory vanishes when the computer is turned off.
  • 14. Ø Computer Hardware Architecture- The Secondary Memory: Is also used to store information, but it is much slower than the main memory. The advantage of the secondary memory is that it can store information even when there is no power to the computer. Examples of secondary memory are disk drives or flash memory (typically found in USB sticks and portable music players).
  • 15. Ø Computer Hardware Architecture- The Input and Output Devices are simply our screen, keyboard, mouse, microphone, speaker, touchpad, etc. They are all of the ways we interact with the computer.
  • 16. Ø What is Python?- Python is a high-level, general-purpose, self-contained programming language designed to meet the needs of computer scientists, software developers, and college students interested in coding Ø History of Python- Is released first in the late 1991 by Guido van Rossum as 0.9.0 Python 2.0 released on 16 October 2000 Python 3.0, released on 03 December 2008
  • 17. Ø Features of Python?- Ø Python is very easy to start programming with and because of flexible syntax, it can be used to almost any kind of software application. Ø Is an open source language that’s free to use. Ø Interpreted Language Ø Dynamically Typed Language Ø Large Standard Library Ø High-Level Language Ø Large Community Support Ø Platform Independent Ø Extensible and Embeddable Ø Graphical User Interface (GUI) Support
  • 18. Ø Features of Python?-
  • 19. Ø Features of Python?-
  • 20. Ø Reserved Keywords in Python- Ø It has very special meaning to Python Ø They have one and only one meaning to Python Ø Writing meaningful own words that has meaning to us is called Variables Ø Has liberty to use any word as a variable but can not use any Python’s reserved words name as a variable Ø So the reserved words are those words in the language where humans talk to Python
  • 21. Ø Reserved Keywords in Python-
  • 22. Ø Values andTypes- A value is one of the basic things a program works with, like a letter or a number. Ex: 1, 2, or 5.4, or “Hello World!” Note- Ø 1, 2 is an integer whereas “Hello World!” is a string. (strings of letter). Ø Human being and interpreter can identify strings easily beacause it is enclosed in a Quotation Marks Ø 5.4 is the floating point Types: Integer (int):- Is that which does not have any fractional part. The print statement also works for integers. Contains negative and positive whole numbers Ex: >>>print(4) 4
  • 23. Ø Values andTypes- Types: Floating-point:- Is that which have a fractional part. The print statement also works for floating point. Ex: >>>print(4.5) 4.5 OR >>>print(1.5*4) 6
  • 24. Ø Values andTypes- Types: Complex Numbers with Imaginary parts:- Is conists of a real part and an imaginary part. Ex:
  • 25. Ø Values andTypes- Type of Value by an Interpreter: >>> type('Hello, World!') <class 'str'> >>> type(17) <class 'int'> >>> type(3.2) <class 'float'> Note- What about values like “17” and “3.2”? >>> type('17') <class 'str'> >>> type('3.2') <class 'str'>
  • 26. Ø Values andTypes- Type of Value by an Interpreter: >>> print(1,000,000) 1 0 0 Ø Python interprets 1,000,000 as a comma separated sequence of integers, which it prints with spaces between. Ø Is known as a semantic error. Ø The code runs without producing an error message, but it doesn’t do the “right” thing.
  • 27. Ø Variables- Ø A variable is a name given to a memory location, that holds or refers to a value. Ø It can contain both letters and numbers, but it cannot start with a number Ø If we give a variable an illegal name, we will get a syntax error: >>> 76trombones = 'big parade' SyntaxError: invalid syntax >>> more@ = 1000000 SyntaxError: invalid syntax >>> class = 'Advanced Theoretical Zymurgy' SyntaxError: invalid syntax
  • 28. Ø Variables- • 76trombones is illegal because it begins with a number • more@ is illegal because it contains an illegal character, @ • What went wrong with class as a variable. It turns out that class is one of Python’s keywords
  • 29. Ø Character Set- Ø It is a valid set of all the valid characters/symbols which can be recognized by the compiler/interpreter Ø Alphabets- “a to z” OR “A to Z” Ø Symbols- Ø Numbers- “0 to 9” Ø Whitespaces- Blank space, tabs, enter, line feed (Newline), Ex- >>>print(“Hello@123”) Ø Lexical structure- Is the set of basic rules that govern how you write programs in that language.
  • 30. Ø Tokens (Lexical Units) in Python- Ø Each logical line (statement) in Python is broken down into a series of lexical components known as tokens. Ø Python converts characters into tokens. Ø Each token corresponds to a substring of the logical line. Note- • Tokens are the smallest and basic fraction in Python program. • Is a set of one or more characters having a meaning together.
  • 31. Ø Statements- Ø A statement is a unit of code (tokens) that the Python interpreter can execute. Ø In simple terms, statements are the things you write to tell Python what your programs should do. Ø By combining statements, you specify a procedure that Python performs to satisfy a program’s goals. Ø Python program structure- 1. Programs are composed of modules. 2. Modules contain statements. 3. Statements contain expressions. 4. Expressions create and process objects.
  • 32. Ø Types of Tokens- i. Identifiers, ii. Keywords, iii. Operators, iv. Delimiters, and v. Literals/Values/Data Identifiers:- Is a name used to identify a variable, function, class, module, or other object. It aids in distinguishing one entity from others.
  • 33. Ø Types of Tokens- Characteristics of Python Identifiers:- • The initial letter of the identifier should be any letter (A to Z or a to z) or underscore (_). • Upper and lower case letters have distinct characteristics. • Except for the initial letter, any digit from 0 to 9 can be part of the identification. • It shouldn’t be used as a keyword • Except for the underscore (_), an identifier cannot contain any special characters such as @, $, and %. • Identifiers can be as long as you want them to be. • Case matters when it comes to identifier names. Myself and myself, for example, are not the same thing.
  • 34. Ø Types of Tokens- Operators:- Ø Is a special symbol when applied to the variables and other objects in an expression, cause a computation or action to occur. There are 7 different operators. i)Arithmetic Operators- It performs all the mathematical calculations. Ex- (+, -, /, *, %,//)
  • 35. Ø Types of Tokens- Operators:- ii) Relational Operator/Comparative Operator- Examines the relationship between two operands. Note- i. Are always in binary form ii. Results are always in Boolean form (i.e True or False)
  • 36. Ø Types of Tokens- Operators:- ii) Relational Operator/Comparative Operator-
  • 37. Ø Types of Tokens- Operators:- iii) Assignment Operators- Employed to allocate a value to a variable. Ex- • (+=)It adds the right side input to the left side input and then assigns the result to the left side input. • (-= )Augmented assignment operator- It takes the right side operand and subtracts it from the left side operand, then assigns the result to the left side operand. Note- i. Are always in binary form ii. Use ‘=’ sign to assign it iii. Have two values ‘Right-value’ and ‘Left-value’; Right-value evaluate first then get assign to Left-value
  • 38. Ø Types of Tokens- Operators:- iii) Assignment Operators-
  • 39. Ø Types of Tokens- Operators:- iv) Logical Operators- Compares the two boolean expressions and yield a boolean result. Ex- • The logical and operator makes a condition true if both operands are true or non-zero. • The logical or operator returns true if one of the two operands is true or non-zero. Note- i. May be Unary or Binary ii. Unary logical operator is not and Binary logical operator is and and or
  • 40. Ø Types of Tokens- Operators:- iv) Logical Operators-
  • 41. Ø Types of Tokens- Operators:- v) Bitwise Operators- It manipulates individual bits in one or more bit patterns or binary numbers. For example, If a binary XOR operator (^) is set in one input value but not both, it copies the matching binary 1 to the result. Note- i. May be Unary or Binary ii. Unary bitwise operator is only one i.e first complement (~) and Binary bitwise operator is and (&), or (|), xor (^), right shift (>>), left shift (<<) iii. Bitwise operator does not work with string and floating point.
  • 42. Ø Types of Tokens- Operators:- v) Bitwise Operators-
  • 43. Ø Types of Tokens- Operators:- vi) Membership Operators- It checks for membership in successions, such as a string, list, or tuple. It fetches a variable and if the variable is found in the supplied sequence, evaluate to true; otherwise, evaluate to false. Note- i. Relational/comparative/arithmetic operators are used to check values only whereas identity operator (in and not in) compares “Id” only not a value. ii. Results are always in Boolean form iii. Ex:>>>print(2 in [1,2,3,4,5,6])→True >>>print(2 in [1,3,4,5,6])→False
  • 44. Ø Types of Tokens- Operators:- vi) Membership Operators-
  • 45. Ø Types of Tokens- Operators:- vii) Identity Operators- When comparing the memory locations of two objects, identity operators are used. If two variables point to separate objects, it does not return true; otherwise, it returns false. Note- i. Is a special feature of Python not available in other languages like C, C++, Java etc. ii. Relational/comparative/arithmetic operators are used to check values only whereas identity operator (is and not is) compares “Id” only not a value. iii. Results are always in Boolean form
  • 46. Ø Types of Tokens- Operators:- vii) Identity Operators-
  • 47. Ø Types of Tokens- Literals:- • Literals, in Python are the data elements (numeric or non-numeric) with a fixed value to be store in variable. Types of Literals- i. String Literals (Text Constants) ii. Numeric Literals. These are further of three types, integer, float, and complex literals. iii. Boolean Literals iv. Literal Collection Note- Lists, tuples, dictionaries, and sets are all examples of literal collections in Python.
  • 48. Ø Types of Tokens- Punctuators OR Separators:- • Punctuators are tokens in python employed to put the grammar and structure of syntax into practice. • Punctuators are symbols that are used to structure programming sentences in a computer language. • Ex- ‘, ‘ ,#, ,( ) ,{ },[ ] ,@ ,: , =
  • 49. Ø Operands- The values that an operator acts on are called operands. Ø Expression- A sequence of operands and operators is called an expression
  • 50. Ø Difference between Expression and Statement- Expression- An expression is a combination of values(Constants), variables and operators. An expression may also include call to functions and objects. Any expression evaluates to a single value, which becomes the value of the expression. Ex:- a = 10 # This is an assignment statement b = 10 # This is an assignment statement print(a + b) # a + b is an expression and print(a + b) is a statement
  • 51. Ø Difference between Expression and Statement- Statements- A statement in Python is a logical instruction which can be read and executed by Python interpreter. Types are- i. Print statements ii. Assignment statements iii. Selective statements iv. Iterative statements v. Function declaration statements
  • 52. Ø Order of operations in Python- • When more than one operator appears in an expression, the order of evaluation depends on the rules of precedence • The acronym PEMDAS is a useful way to remember the rules: Ø Parentheses have the highest precedence. Ø Expressions in parentheses are evaluated first, 2 * (3- 1) is 4, and (1+1)**(5-2) is 8. Ø Even we can use parentheses to make an expression easier to read, as in (minute * 100) /60, even if it doesn’t change the result. Ø Exponentiation has the next highest precedence, so 2**1+1 is 3, not 4, and 3*1**3 is 3, not 27.
  • 53. Ø Order of operations in Python- Ø Multiplication and Division have the same precedence, which is higher than Addition and Subtraction, which also have the same precedence. So 2*3-1 is 5, not 4, and 6+4/2 is 8, not 5. Ø Operators with the same precedence are evaluated from left to right. So the expression 5-3-1 is 1, not 3, because the 5-3 happens first and then 1 is subtracted from 2. Note- When in doubt, always put parentheses in your expressions to make sure the computations are performed in the order you intend.
  • 54. Ø Order of operations in Python- Example:- (43+13−9/3∗ 7) i. From left to right, 9/3∗ 7= 3∗ 7= 21 ii. Expression has become, 43+13−21 iii. Left to right Associativiy rule will be followed again. So, the final value of expression will be- 43+13−21 = 56−21= 35
  翻译: