SlideShare a Scribd company logo
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
Fundamentals of Python Programming
•Interactive, interpreted, and object-oriented
programming language.
• Platform independent.
•Simple syntax, Free and Open source.
• Portable, extensible and expandable.
• Large standard libraries to solve a task.
•Developed by Guido Van Rossum in 1991 at the
National Research Institute for Mathematics and
Computer Science in the Netherlands.
•Name was inspired by: Monty Python’s Flying
Circus.
• Allows to distinguish input, output, and error
messages by different colour codes.
PYTHON PROGRAMMING ENVIRONMENT
• Available on a wide variety of platforms including Windows,
Linux and Mac OS X.
• Official Website: python.org
• IDLE stands for Integrated Development and Learning
Environment. Python IDLE comprises of Python Shell and
Python Editor.
Python Shell Python Editor
• Reserved words that are already defined by the
Python for specific uses.
In [ ]: import keyword
print(keyword.kwlist)
Sample Python Command Line Expressions
Display on screen
In [2]: print('hello world')
hello world
Since, Python is a case-sensitive language so print and
PRINT are different.
Names (Variables) and Assignment Statements
• Variables provide a means to name values so that they can be
used and manipulated later.
• Assignment Statement: Statement that assigns value to a
variable.
In [ ]: Maths = 87
print(Maths)
87
Python associates the name (variable) Maths with value 87 i.e.
the name (variable) Maths is assigned the value 87, or that the
name (variable) Maths refers to value 87. Values are also called
objects.
Multiple Assignments
•Used to enhance the readability of the program.
>>> msg, day, time='Meeting','Mon','9‘
>>> print (msg,day,time)
Meeting Mon 9
totalMarks = count = 0
Data Types and Associating them with variables
Arithmetic Operators
print("18 + 5 =", 18 + 5)
print("18 - 5 =", 18 - 5)
print("18 * 5 =", 18 * 5)
print("27 / 5 =", 27 / 5)
print("27 // 5 =", 27 // 5)
print("27 5 =", 27 5)
print("2 ** 3 =", 2 ** 3)
print("-2 ** 3 =", -2 ** 3)
18 + 5 = 23
18 - 5 = 13
18 * 5 = 90
27 / 5 = 5.4
27 // 5 = 5
27 5 = 2
2 ** 3 = 8
-2 ** 3 = -8
#Addition
#Subtraction
#Multiplication
#Division
#Integer Division
#Modulus
#Exponentiation
#Exponentiation
Precedence of Arithmetic Operators
Operators in Python
Relational Operators
• Used for comparing two expressions and yield True or False.
• The arithmetic operators have higher precedence than the
relational operators.
print("23 < 25 :", 23 < 25)
print("23 > 25 :", 23 > 25)
print("23 <= 23 :", 23 <= 23) #less than or equal to
print("23 - 2.5 >= 5 * 4 :", 23 - 2.5 >= 5 * 4) #greater than or equal to
print("23 == 25 :", 23 == 25)
print("23 != 25 :", 23 != 25)
• When the relational operators are applied to strings, strings are compared
left to right, char- acter by character, based on their ASCII codes, also called
ASCII values.
print("'hello' < 'Hello' :", 'hello' < 'Hello')
print("'hi' > 'hello' :", 'hi' > 'hello')
'hello' < 'Hello' : False
'hi' > 'hello' : True
#less than
#greater than
#equal to
#not equal to
Logical Operators
• The logical operators not, and, and or are applied to logical
operands True and False, also called Boolean values, and yield
either True or False.
• As compared to relational and arithmetic operators, logical
operators have the least precedence level.
print("not True < 25
print("10 < 25 and 5 >6
print("10 < 25 or 5 > 6
:", not True) #not operator
:", 10 < 25 and 5 > 6) #and operator
:", 10 < 25 or 5 > 6) #or operator
Identity Operators
Precedence of Operators
Functions
• Functions provide a systematic way of problem solving by dividing the
given problem into several sub-problems, finding their individual
solutions, and integrating the solutions of individual problems to solve
the original problem.
• This approach to problem solving is called stepwise refinement method
or modular approach.
Built-in Functions
• Predefined functions that are already available in Python.
Type Conversion: int, float, str functions
>>>str(123)
'123'
>>>int('234')
234
>>>int(234.8)
234
input function
• Enables us to accept an input string from the user
without evaluating its value.
• The function input continues to read input text from the user until it
encounters a newline.
>>>name = input('Enter your name: ')
print('Welcome', name)
Enter your name: Yogesh
Welcome Yogesh
costPrice = int(input('Enter cost price: '))
profit = int(input('Enter profit: '))
sellingPrice = costPrice + profit
print('Selling Price: ' , sellingPrice)
Enter cost price: 50
Enter profit: 12
Selling Price: 62
Another
Example: To find
the profit earned
on an item
Function Definition and Call
The syntax for a function definition is as follows:
def function_name ( comma_separated_list_of_parameters):
statements
Note: Statements below def begin with four spaces. This is called indentation. It is a
require-ment of Python that the code following a colon must be indented.
def triangle():
' ' '
Objective: To print a right angled triangle. Input
Parameter: None
Return Value: None
' ' '
' ' '
Approach: To use a print statement for each line of output
' ' '
print('*')
print('* *')
print('* * *')
print('* * * *')
User-Defined Functions
Invoking the function
>>>triangle()
*
* *
* * *
* * * *
Computing Area of the Rectangle
def areaRectangle(length, breadth):
' ' '
Objective: To compute the area of rectangle Input
Parameters: length, breadth numeric value Return
Value: area - numeric value
' ' '
area = length * breadth
return area
>>>areaRectangle(7,5)
35
>>>help(areaRectangle) #help on any function
Help on function areaRectangle in module main :
areaRectangle(length, breadth)
Objective: To compute the area of rectangle
Input Parameters: length, breadth numeric value
Return Value: area - numeric value
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
#This else is for break and not for if statement
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
Strings, Lists, and
Dictionary
Strings
• A string is a sequence of characters.
• A string may be specified by placing the member characters of
the sequence within quotes
(single, double or triple).
• Triple quotes are typically used for strings that span multiple
lines.
>>>message = 'Hello Gita'
Computing Length using len function
>>>print(len(message))
10
Indexing
• Individual characters within a string are accessed using a technique
known as indexing.
>>>index = len(message) - 1
>>>print(message[0], message[6], message[index], message[-1])
H G a a
>>>print(message[15])
IndexError Traceback (most recent call last)
<ipython-input-4-a801df50d8d1> in <module>()
Slicing
• In order to extract the substring comprising the character sequence
having indices from start to end-1, we specify the range in the form
start:end.
• Python also allows us to extract a subsequence of the form
start:end:inc.
>>>message = 'Hello Sita'
>>>print(message[0:5], message[-10:-5])
Hello Hello
>>>print(message[0:len(message):2])
>>>print(message[:])
HloSt
Hello Sita
Membership Operator in
• Python also allows us to check for membership of the individual
characters or substrings in
strings using in operator.
>>>'h' in 'hello'
True
>>>'ell' in 'hello'
True
>>>'h' in 'Hello'
False
Lists
• A list is an ordered sequence of values.
• Values stored in a list can be of any type such as string, integer, float,
or list.
• Note!! Elements of a list are enclosed in square brackets, separated by
commas.
• Unlike strings, lists are mutable, and therefore, one may modify
individual elements of a list.
>>>subjects=['Hindi', 'English', 'Maths', 'History']
>>>temporary = subjects
>>>temporary[0] = 'Sanskrit'
>>>print(temporary)
>>>print(subjects)
['Sanskrit', 'English', 'Maths', 'History']
['Sanskrit', 'English', 'Maths', 'History']
>>>subjectCodes = [['Sanskrit', 43], ['English', 85] , ['Maths', 65],
['History', 36]]
>>>subjectCodes[1]
['English', 85]
>>>print(subjectCodes[1][0],subjectCodes[1][1])
English 85
List Operations
>>>list1 = ['Red', 'Green']
list2 = [10, 20, 30]
Multiple Operator *
>>>list2 * 2
[10, 20, 30, 10, 20, 30]
Concatenation Operator +
>>> list1 = list1 + ['Blue']
>>>list1
['Red', 'Green', 'Blue']
Length Operator len
>>>len(list1)
3
Indexing & Slicing
>>>list2[-1]
30
>>>list2[0:2]
[10, 20]
>>>list2[0:3:2]
[10, 30]
Function min & max
>>>min(list2)
10
>>>max(list1)
'Red'
Membership Operator: in
>>>40 in list2
False
>>>students = ['Ram', 'Shyam', 'Gita', 'Sita']
for name in students:
print(name)
Ram
Shyam
Gita
Sita
Dictionary { }
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
Ad

More Related Content

Similar to CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx (20)

Python basics
Python basicsPython basics
Python basics
Luis Goldster
 
Python basics
Python basicsPython basics
Python basics
Young Alista
 
Unit2 input output
Unit2 input outputUnit2 input output
Unit2 input output
deepak kumbhar
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
Pythonppt28 11-18
Pythonppt28 11-18Pythonppt28 11-18
Pythonppt28 11-18
Saraswathi Murugan
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)
ExcellenceAcadmy
 
Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)
ExcellenceAcadmy
 
c-programming
c-programmingc-programming
c-programming
Zulhazmi Harith
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
Review of C programming language.pptx...
Review of C programming language.pptx...Review of C programming language.pptx...
Review of C programming language.pptx...
SthitaprajnaLenka1
 
C
CC
C
Jerin John
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
Girish Khanzode
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 
03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
Pythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptxPythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
Introduction to Python Prog. - Lecture 2
Introduction to Python Prog. - Lecture 2Introduction to Python Prog. - Lecture 2
Introduction to Python Prog. - Lecture 2
Faculty of Computers and Informatics, Suez Canal University, Ismailia, Egypt
 
C programming language
C programming languageC programming language
C programming language
Abin Rimal
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
Manzoor ALam
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
Saraswathi Murugan
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)
ExcellenceAcadmy
 
Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)
ExcellenceAcadmy
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
Review of C programming language.pptx...
Review of C programming language.pptx...Review of C programming language.pptx...
Review of C programming language.pptx...
SthitaprajnaLenka1
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 
03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf03-Variables, Expressions and Statements (1).pdf
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
Pythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptxPythonlearn-02-Expressions123AdvanceLevel.pptx
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
C programming language
C programming languageC programming language
C programming language
Abin Rimal
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
Manzoor ALam
 

Recently uploaded (20)

Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Ad

CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx

  • 2. Fundamentals of Python Programming •Interactive, interpreted, and object-oriented programming language. • Platform independent. •Simple syntax, Free and Open source. • Portable, extensible and expandable. • Large standard libraries to solve a task. •Developed by Guido Van Rossum in 1991 at the National Research Institute for Mathematics and Computer Science in the Netherlands. •Name was inspired by: Monty Python’s Flying Circus. • Allows to distinguish input, output, and error messages by different colour codes.
  • 3. PYTHON PROGRAMMING ENVIRONMENT • Available on a wide variety of platforms including Windows, Linux and Mac OS X. • Official Website: python.org • IDLE stands for Integrated Development and Learning Environment. Python IDLE comprises of Python Shell and Python Editor. Python Shell Python Editor
  • 4. • Reserved words that are already defined by the Python for specific uses. In [ ]: import keyword print(keyword.kwlist)
  • 5. Sample Python Command Line Expressions Display on screen In [2]: print('hello world') hello world Since, Python is a case-sensitive language so print and PRINT are different.
  • 6. Names (Variables) and Assignment Statements • Variables provide a means to name values so that they can be used and manipulated later. • Assignment Statement: Statement that assigns value to a variable. In [ ]: Maths = 87 print(Maths) 87 Python associates the name (variable) Maths with value 87 i.e. the name (variable) Maths is assigned the value 87, or that the name (variable) Maths refers to value 87. Values are also called objects.
  • 7. Multiple Assignments •Used to enhance the readability of the program. >>> msg, day, time='Meeting','Mon','9‘ >>> print (msg,day,time) Meeting Mon 9 totalMarks = count = 0 Data Types and Associating them with variables
  • 8. Arithmetic Operators print("18 + 5 =", 18 + 5) print("18 - 5 =", 18 - 5) print("18 * 5 =", 18 * 5) print("27 / 5 =", 27 / 5) print("27 // 5 =", 27 // 5) print("27 5 =", 27 5) print("2 ** 3 =", 2 ** 3) print("-2 ** 3 =", -2 ** 3) 18 + 5 = 23 18 - 5 = 13 18 * 5 = 90 27 / 5 = 5.4 27 // 5 = 5 27 5 = 2 2 ** 3 = 8 -2 ** 3 = -8 #Addition #Subtraction #Multiplication #Division #Integer Division #Modulus #Exponentiation #Exponentiation Precedence of Arithmetic Operators Operators in Python
  • 9. Relational Operators • Used for comparing two expressions and yield True or False. • The arithmetic operators have higher precedence than the relational operators. print("23 < 25 :", 23 < 25) print("23 > 25 :", 23 > 25) print("23 <= 23 :", 23 <= 23) #less than or equal to print("23 - 2.5 >= 5 * 4 :", 23 - 2.5 >= 5 * 4) #greater than or equal to print("23 == 25 :", 23 == 25) print("23 != 25 :", 23 != 25) • When the relational operators are applied to strings, strings are compared left to right, char- acter by character, based on their ASCII codes, also called ASCII values. print("'hello' < 'Hello' :", 'hello' < 'Hello') print("'hi' > 'hello' :", 'hi' > 'hello') 'hello' < 'Hello' : False 'hi' > 'hello' : True #less than #greater than #equal to #not equal to
  • 10. Logical Operators • The logical operators not, and, and or are applied to logical operands True and False, also called Boolean values, and yield either True or False. • As compared to relational and arithmetic operators, logical operators have the least precedence level. print("not True < 25 print("10 < 25 and 5 >6 print("10 < 25 or 5 > 6 :", not True) #not operator :", 10 < 25 and 5 > 6) #and operator :", 10 < 25 or 5 > 6) #or operator Identity Operators
  • 12. Functions • Functions provide a systematic way of problem solving by dividing the given problem into several sub-problems, finding their individual solutions, and integrating the solutions of individual problems to solve the original problem. • This approach to problem solving is called stepwise refinement method or modular approach. Built-in Functions • Predefined functions that are already available in Python. Type Conversion: int, float, str functions >>>str(123) '123' >>>int('234') 234 >>>int(234.8) 234
  • 13. input function • Enables us to accept an input string from the user without evaluating its value. • The function input continues to read input text from the user until it encounters a newline. >>>name = input('Enter your name: ') print('Welcome', name) Enter your name: Yogesh Welcome Yogesh costPrice = int(input('Enter cost price: ')) profit = int(input('Enter profit: ')) sellingPrice = costPrice + profit print('Selling Price: ' , sellingPrice) Enter cost price: 50 Enter profit: 12 Selling Price: 62 Another Example: To find the profit earned on an item
  • 14. Function Definition and Call The syntax for a function definition is as follows: def function_name ( comma_separated_list_of_parameters): statements Note: Statements below def begin with four spaces. This is called indentation. It is a require-ment of Python that the code following a colon must be indented. def triangle(): ' ' ' Objective: To print a right angled triangle. Input Parameter: None Return Value: None ' ' ' ' ' ' Approach: To use a print statement for each line of output ' ' ' print('*') print('* *') print('* * *') print('* * * *') User-Defined Functions Invoking the function >>>triangle() * * * * * * * * * *
  • 15. Computing Area of the Rectangle def areaRectangle(length, breadth): ' ' ' Objective: To compute the area of rectangle Input Parameters: length, breadth numeric value Return Value: area - numeric value ' ' ' area = length * breadth return area >>>areaRectangle(7,5) 35 >>>help(areaRectangle) #help on any function Help on function areaRectangle in module main : areaRectangle(length, breadth) Objective: To compute the area of rectangle Input Parameters: length, breadth numeric value Return Value: area - numeric value
  • 20. #This else is for break and not for if statement
  • 24. Strings • A string is a sequence of characters. • A string may be specified by placing the member characters of the sequence within quotes (single, double or triple). • Triple quotes are typically used for strings that span multiple lines. >>>message = 'Hello Gita' Computing Length using len function >>>print(len(message)) 10 Indexing • Individual characters within a string are accessed using a technique known as indexing. >>>index = len(message) - 1 >>>print(message[0], message[6], message[index], message[-1]) H G a a >>>print(message[15]) IndexError Traceback (most recent call last) <ipython-input-4-a801df50d8d1> in <module>()
  • 25. Slicing • In order to extract the substring comprising the character sequence having indices from start to end-1, we specify the range in the form start:end. • Python also allows us to extract a subsequence of the form start:end:inc. >>>message = 'Hello Sita' >>>print(message[0:5], message[-10:-5]) Hello Hello >>>print(message[0:len(message):2]) >>>print(message[:]) HloSt Hello Sita Membership Operator in • Python also allows us to check for membership of the individual characters or substrings in strings using in operator. >>>'h' in 'hello' True >>>'ell' in 'hello' True >>>'h' in 'Hello' False
  • 26. Lists • A list is an ordered sequence of values. • Values stored in a list can be of any type such as string, integer, float, or list. • Note!! Elements of a list are enclosed in square brackets, separated by commas. • Unlike strings, lists are mutable, and therefore, one may modify individual elements of a list. >>>subjects=['Hindi', 'English', 'Maths', 'History'] >>>temporary = subjects
  • 27. >>>temporary[0] = 'Sanskrit' >>>print(temporary) >>>print(subjects) ['Sanskrit', 'English', 'Maths', 'History'] ['Sanskrit', 'English', 'Maths', 'History'] >>>subjectCodes = [['Sanskrit', 43], ['English', 85] , ['Maths', 65], ['History', 36]] >>>subjectCodes[1] ['English', 85] >>>print(subjectCodes[1][0],subjectCodes[1][1]) English 85 List Operations >>>list1 = ['Red', 'Green'] list2 = [10, 20, 30] Multiple Operator * >>>list2 * 2 [10, 20, 30, 10, 20, 30] Concatenation Operator + >>> list1 = list1 + ['Blue'] >>>list1 ['Red', 'Green', 'Blue']
  • 28. Length Operator len >>>len(list1) 3 Indexing & Slicing >>>list2[-1] 30 >>>list2[0:2] [10, 20] >>>list2[0:3:2] [10, 30] Function min & max >>>min(list2) 10 >>>max(list1) 'Red' Membership Operator: in >>>40 in list2 False >>>students = ['Ram', 'Shyam', 'Gita', 'Sita'] for name in students: print(name) Ram Shyam Gita Sita
  翻译: