SlideShare a Scribd company logo
Programming in Python
Vikram Neerugatti
content
• Introduction to python
• Installation of Python in windows
• Running Python
• Arithmetic operators
• Values and types
• Formal and Natural languages
Introduction to Python
• Dynamic interoperated language that allows both functional and object oriented programming languages
• Interpreter
• Python is a language
• Simple
• On all platforms
• Real programming language
• High level problems
• Can split into modules
• GUI can be done
• It is a interpreter language
• Very short compare with other languages
• Indents will be used instead of brackets
• After the bbc shows monty python cant do anything on reptiles
Installation of Python in windows
Installation of Python in windows
Installation of Python in windows
Running a python
• Start
• Select python
• In the prompt type the statement
Print (“hello world”)
Arithmetic operations
• In the prompt of the python type
• 3+4
• 3-4
• ¾
• 3%4
• 3*4
• Type with variables also
• A=3
• B=5, etc.
Values and types
• Python numbers
• Integer
• 2,4,5
• Float
• 2.3,4.5,7.8
• Complex
• 3+5J
• Python lists
• can be any
• [3, 4, 5, 6, 7, 9]
• ['m', 4, 4, 'nani']
• Slicing operator, list index starts from zero
• A[4],a[:2],a[1:2]
• mutable
• Python tuples ()
• Cannot change, slicing can be done a[4].
• immutable
Values and types
• Python Strings
• Sequence of Characters
• Single line
• Ex. s='zaaaa nani'
• Multi line
• Ex. s='''zaaaa nani
• print(s)
• nani'''
• print (s)
• Sliicing can be done
• Ex. S[5]
Values and types
• Python sets
• Collection of unordered elements, elements will not be in order
• S={3,4,5.6,’g’,8}
• Can do intersection (&), union(|), difference (-), ^ etc.
• Ex. A&b, a|b, a-b, a^b’
• Remove duplicates
• {5,5,5,7,88,8,88}
• No slicing can be done, because elements are not in order.
• Python dictionaries
Python dictionaries
• Python dictionary is an unordered collection of items.
• While other compound data types have only value as an element, a
dictionary has a key: value pair.
• Dictionaries are optimized to retrieve values when the key is known.
• Creating a dictionary is as simple as placing items inside curly braces {}
separated by comma.
• An item has a key and the corresponding value expressed as a pair, key:
value.
• While values can be of any data type and can repeat, keys must be of
immutable type (string, number or tuple with immutable elements) and
must be unique.
Python dictionaries (creating)
1.# empty dictionary
2.my_dict = {}
4.# dictionary with integer keys
5.my_dict = {1: 'apple', 2: 'ball'}
7.# dictionary with mixed keys
8.my_dict = {'name': 'John', 1: [2, 4, 3]}
10.# using dict()
11.my_dict = dict({1:'apple', 2:'ball'})
13.# from sequence having each item as a pair
14.my_dict = dict([(1,'apple'), (2,'ball')])
Python dictionaries (accesing)
• my_dict = {'name':'Jack', 'age': 26}
• # Output: Jack
• print(my_dict['name’])
• # Output: 26
• print(my_dict.get('age’))
• # Trying to access keys which doesn't exist throws error#
my_dict.get('address’)
• # my_dict['address’]
• Key in square brackets/get(), if you use get(), instead of error , none will be
displayed.
Change/ add elements in a dictionaries
• my_dict = {'name':'Jack', 'age': 26}
• # update value
• my_dict['age'] = 27
• #Output: {'age': 27, 'name': 'Jack’}
• print(my_dict)
• # add item
• my_dict['address'] = 'Downtown’
• # Output: {'address': 'Downtown', 'age': 27, 'name': 'Jack'}print(my_dict)
• Mutable, if key is there: value will be updated, if not created new one.
How to remove or delete the item in
dictionaries
• We can remove a particular item in a dictionary by using the method
pop(). This method removes as item with the provided key and
returns the value.
• The method, popitem() can be used to remove and return an
arbitrary item (key, value) form the dictionary. All the items can be
removed at once using the clear() method.
• We can also use the del keyword to remove individual items or the
entire dictionary itself.
How to remove or delete the item in
dictionaries
• # create a dictionary squares = {1:1, 2:4, 3:9, 4:16, 5:25}
• # remove a particular item # Output: 16
• print(squares.pop(4)) # Output: {1: 1, 2: 4, 3: 9, 5: 25}print(squares)
• # remove an arbitrary item
• # Output: (1, 1) print(squares.popitem()) # Output: {2: 4, 3: 9, 5: 25} print(squares)
• # delete a particular item
• del squares[5] # Output: {2: 4, 3: 9}print(squares)
• # remove all items
• squares.clear()
• # Output: {}
• print(squares)
• # delete the dictionary itself
• del squares
• # Throws Error# print(squares)
Programming in python Unit-1 Part-1
Programming in python Unit-1 Part-1
Nested Dictionary
• In Python, a nested dictionary is a dictionary inside a dictionary.
• It's a collection of dictionaries into one single dictionary.
Example:
nested_dict = { 'dictA': {'key_1': 'value_1’},
'dictB': {'key_2': 'value_2'}}
• Here, the nested_dict is a nested dictionary with the dictionary dictA
and dictB.
• They are two dictionary each having own key and value.
Nested dictionaries
Example:
>>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female’}}
>>print(people)
#Accessing elements
>>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female’}}
>>print(people[1]['name’])
>>print(people[1]['age’])
>>print(people[1]['sex'])
Add or updated the nested dictionaries
>>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female’}}
>>people[3] = {}
>>people[3]['name'] = 'Luna’
>>people[3]['age'] = '24’
>>people[3]['sex'] = 'Female’
>>people[3]['married'] = 'No’
>>print(people[3])
Add another dictionary
>>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female'},
3: {'name': 'Luna', 'age': '24', 'sex': 'Female', 'married': 'No’}}
>>people[4] = {'name': 'Peter', 'age': '29', 'sex': 'Male', 'married’:
'Yes’}
>>print(people[4]);
Delete elements from the dictionaries
>>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female'},
3: {'name': 'Luna', 'age': '24', 'sex': 'Female', 'married': 'No'},
4: {'name': 'Peter', 'age': '29', 'sex': 'Male', 'married': 'Yes’}}
>>del people[3]['married’]
>>del people[4]['married’]
>>print(people[3])
>>print(people[4])
How to delete the dictionary
>>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female'},
3: {'name': 'Luna', 'age': '24', 'sex': 'Female'},
4: {'name': 'Peter', 'age': '29', 'sex': 'Male’}}
>>del people[3], people[4]
>>print(people)
Natural Language and Formal Language
• The languages used by the humans called as a natural languages
• Examples: English, French, Telugu,etc.
• The languages designed and developed by the humans to
communicate with the machines is called as the formal languages.
• Example: C, C++, Java, Python, etc.
Summary
• Introduction to python
• Installation of Python in windows
• Running Python
• Arithmetic operators
• Values and types
• Formal and Natural languages
Any questions
• vikramneerugatti@gmail.com
• www.vikramneerugatti.com

More Related Content

What's hot (19)

Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
Shani729
 
1. python
1. python1. python
1. python
PRASHANT OJHA
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Truth, deduction, computation; lecture 2
Truth, deduction, computation;   lecture 2Truth, deduction, computation;   lecture 2
Truth, deduction, computation; lecture 2
Vlad Patryshev
 
Greach 2015 AST – Groovy Transformers: More than meets the eye!
Greach 2015   AST – Groovy Transformers: More than meets the eye!Greach 2015   AST – Groovy Transformers: More than meets the eye!
Greach 2015 AST – Groovy Transformers: More than meets the eye!
Iván López Martín
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy Annotations
Iván López Martín
 
Python Training
Python TrainingPython Training
Python Training
TIB Academy
 
Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
Mohammed Sikander
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
hydpy
 
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212
Mahmoud Samir Fayed
 
Python in 90 minutes
Python in 90 minutesPython in 90 minutes
Python in 90 minutes
Bardia Heydari
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
Sujith Kumar
 
.net F# mutable dictionay
.net F# mutable dictionay.net F# mutable dictionay
.net F# mutable dictionay
DrRajeshreeKhande
 
Madrid gug - sacando partido a las transformaciones ast de groovy
Madrid gug - sacando partido a las transformaciones ast de groovyMadrid gug - sacando partido a las transformaciones ast de groovy
Madrid gug - sacando partido a las transformaciones ast de groovy
Iván López Martín
 
The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184
Mahmoud Samir Fayed
 
Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018
Garth Gilmour
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examples
Nebojša Vukšić
 
DevNation'15 - Using Lambda Expressions to Query a Datastore
DevNation'15 - Using Lambda Expressions to Query a DatastoreDevNation'15 - Using Lambda Expressions to Query a Datastore
DevNation'15 - Using Lambda Expressions to Query a Datastore
Xavier Coulon
 
The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185
Mahmoud Samir Fayed
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
Shani729
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Truth, deduction, computation; lecture 2
Truth, deduction, computation;   lecture 2Truth, deduction, computation;   lecture 2
Truth, deduction, computation; lecture 2
Vlad Patryshev
 
Greach 2015 AST – Groovy Transformers: More than meets the eye!
Greach 2015   AST – Groovy Transformers: More than meets the eye!Greach 2015   AST – Groovy Transformers: More than meets the eye!
Greach 2015 AST – Groovy Transformers: More than meets the eye!
Iván López Martín
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy Annotations
Iván López Martín
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
hydpy
 
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212
Mahmoud Samir Fayed
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
Sujith Kumar
 
Madrid gug - sacando partido a las transformaciones ast de groovy
Madrid gug - sacando partido a las transformaciones ast de groovyMadrid gug - sacando partido a las transformaciones ast de groovy
Madrid gug - sacando partido a las transformaciones ast de groovy
Iván López Martín
 
The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184The Ring programming language version 1.5.3 book - Part 6 of 184
The Ring programming language version 1.5.3 book - Part 6 of 184
Mahmoud Samir Fayed
 
Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018
Garth Gilmour
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examples
Nebojša Vukšić
 
DevNation'15 - Using Lambda Expressions to Query a Datastore
DevNation'15 - Using Lambda Expressions to Query a DatastoreDevNation'15 - Using Lambda Expressions to Query a Datastore
DevNation'15 - Using Lambda Expressions to Query a Datastore
Xavier Coulon
 
The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185The Ring programming language version 1.5.4 book - Part 6 of 185
The Ring programming language version 1.5.4 book - Part 6 of 185
Mahmoud Samir Fayed
 

Similar to Programming in python Unit-1 Part-1 (20)

Chapter 3-Data structure in python programming.pptx
Chapter 3-Data structure in python programming.pptxChapter 3-Data structure in python programming.pptx
Chapter 3-Data structure in python programming.pptx
atharvdeshpande20
 
Dictionary in python Dictionary in python Dictionary in pDictionary in python...
Dictionary in python Dictionary in python Dictionary in pDictionary in python...Dictionary in python Dictionary in python Dictionary in pDictionary in python...
Dictionary in python Dictionary in python Dictionary in pDictionary in python...
sumanthcmcse
 
ComandosDePython_ComponentesBasicosImpl.ppt
ComandosDePython_ComponentesBasicosImpl.pptComandosDePython_ComponentesBasicosImpl.ppt
ComandosDePython_ComponentesBasicosImpl.ppt
oscarJulianPerdomoCh1
 
Python dictionaries
Python dictionariesPython dictionaries
Python dictionaries
Krishna Nanda
 
Session10_Dictionaries.ppggyyyyyyyyyggggggggtx
Session10_Dictionaries.ppggyyyyyyyyyggggggggtxSession10_Dictionaries.ppggyyyyyyyyyggggggggtx
Session10_Dictionaries.ppggyyyyyyyyyggggggggtx
pawankamal3
 
Dictionary.pptx
Dictionary.pptxDictionary.pptx
Dictionary.pptx
RishuVerma34
 
Seventh session
Seventh sessionSeventh session
Seventh session
AliMohammad155
 
Data Type In Python.pptx
Data Type In Python.pptxData Type In Python.pptx
Data Type In Python.pptx
hothyfa
 
Week 10.pptx
Week 10.pptxWeek 10.pptx
Week 10.pptx
CruiseCH
 
Dictionaries in Python programming for btech students
Dictionaries in Python programming for btech studentsDictionaries in Python programming for btech students
Dictionaries in Python programming for btech students
chandinignits
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
cover every basics of python with this..
cover every basics of python with this..cover every basics of python with this..
cover every basics of python with this..
karkimanish411
 
Tuples, sets and dictionaries-Programming in Python
Tuples, sets and dictionaries-Programming in PythonTuples, sets and dictionaries-Programming in Python
Tuples, sets and dictionaries-Programming in Python
ssuser2868281
 
Dictionaries.pptx
Dictionaries.pptxDictionaries.pptx
Dictionaries.pptx
akshat205573
 
Python data structures
Python data structuresPython data structures
Python data structures
kalyanibedekar
 
fundamental of python --- vivek singh shekawat
fundamental  of python --- vivek singh shekawatfundamental  of python --- vivek singh shekawat
fundamental of python --- vivek singh shekawat
shekhawatasshp
 
Revision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docRevision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.doc
SrikrishnaVundavalli
 
Python introduction data structures lists etc
Python introduction data structures lists etcPython introduction data structures lists etc
Python introduction data structures lists etc
ssuser26ff68
 
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
Untitled dictionary in python program .pdf.pptx
Untitled dictionary in python program .pdf.pptxUntitled dictionary in python program .pdf.pptx
Untitled dictionary in python program .pdf.pptx
SnehasisGhosh10
 
Chapter 3-Data structure in python programming.pptx
Chapter 3-Data structure in python programming.pptxChapter 3-Data structure in python programming.pptx
Chapter 3-Data structure in python programming.pptx
atharvdeshpande20
 
Dictionary in python Dictionary in python Dictionary in pDictionary in python...
Dictionary in python Dictionary in python Dictionary in pDictionary in python...Dictionary in python Dictionary in python Dictionary in pDictionary in python...
Dictionary in python Dictionary in python Dictionary in pDictionary in python...
sumanthcmcse
 
ComandosDePython_ComponentesBasicosImpl.ppt
ComandosDePython_ComponentesBasicosImpl.pptComandosDePython_ComponentesBasicosImpl.ppt
ComandosDePython_ComponentesBasicosImpl.ppt
oscarJulianPerdomoCh1
 
Session10_Dictionaries.ppggyyyyyyyyyggggggggtx
Session10_Dictionaries.ppggyyyyyyyyyggggggggtxSession10_Dictionaries.ppggyyyyyyyyyggggggggtx
Session10_Dictionaries.ppggyyyyyyyyyggggggggtx
pawankamal3
 
Data Type In Python.pptx
Data Type In Python.pptxData Type In Python.pptx
Data Type In Python.pptx
hothyfa
 
Week 10.pptx
Week 10.pptxWeek 10.pptx
Week 10.pptx
CruiseCH
 
Dictionaries in Python programming for btech students
Dictionaries in Python programming for btech studentsDictionaries in Python programming for btech students
Dictionaries in Python programming for btech students
chandinignits
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
cover every basics of python with this..
cover every basics of python with this..cover every basics of python with this..
cover every basics of python with this..
karkimanish411
 
Tuples, sets and dictionaries-Programming in Python
Tuples, sets and dictionaries-Programming in PythonTuples, sets and dictionaries-Programming in Python
Tuples, sets and dictionaries-Programming in Python
ssuser2868281
 
Python data structures
Python data structuresPython data structures
Python data structures
kalyanibedekar
 
fundamental of python --- vivek singh shekawat
fundamental  of python --- vivek singh shekawatfundamental  of python --- vivek singh shekawat
fundamental of python --- vivek singh shekawat
shekhawatasshp
 
Revision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docRevision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.doc
SrikrishnaVundavalli
 
Python introduction data structures lists etc
Python introduction data structures lists etcPython introduction data structures lists etc
Python introduction data structures lists etc
ssuser26ff68
 
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
Untitled dictionary in python program .pdf.pptx
Untitled dictionary in python program .pdf.pptxUntitled dictionary in python program .pdf.pptx
Untitled dictionary in python program .pdf.pptx
SnehasisGhosh10
 
Ad

More from Vikram Nandini (20)

IoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold BarIoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold Bar
Vikram Nandini
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Vikram Nandini
 
Linux File Trees and Commands
Linux File Trees and CommandsLinux File Trees and Commands
Linux File Trees and Commands
Vikram Nandini
 
Introduction to Linux & Basic Commands
Introduction to Linux & Basic CommandsIntroduction to Linux & Basic Commands
Introduction to Linux & Basic Commands
Vikram Nandini
 
INTRODUCTION to OOAD
INTRODUCTION to OOADINTRODUCTION to OOAD
INTRODUCTION to OOAD
Vikram Nandini
 
Ethics
EthicsEthics
Ethics
Vikram Nandini
 
Manufacturing - II Part
Manufacturing - II PartManufacturing - II Part
Manufacturing - II Part
Vikram Nandini
 
Manufacturing
ManufacturingManufacturing
Manufacturing
Vikram Nandini
 
Business Models
Business ModelsBusiness Models
Business Models
Vikram Nandini
 
Prototyping Online Components
Prototyping Online ComponentsPrototyping Online Components
Prototyping Online Components
Vikram Nandini
 
Artificial Neural Networks
Artificial Neural NetworksArtificial Neural Networks
Artificial Neural Networks
Vikram Nandini
 
IoT-Prototyping
IoT-PrototypingIoT-Prototyping
IoT-Prototyping
Vikram Nandini
 
Design Principles for Connected Devices
Design Principles for Connected DevicesDesign Principles for Connected Devices
Design Principles for Connected Devices
Vikram Nandini
 
Introduction to IoT
Introduction to IoTIntroduction to IoT
Introduction to IoT
Vikram Nandini
 
Embedded decices
Embedded decicesEmbedded decices
Embedded decices
Vikram Nandini
 
Communication in the IoT
Communication in the IoTCommunication in the IoT
Communication in the IoT
Vikram Nandini
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber Security
Vikram Nandini
 
cloud computing UNIT-2.pdf
cloud computing UNIT-2.pdfcloud computing UNIT-2.pdf
cloud computing UNIT-2.pdf
Vikram Nandini
 
Introduction to Web Technologies
Introduction to Web TechnologiesIntroduction to Web Technologies
Introduction to Web Technologies
Vikram Nandini
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Vikram Nandini
 
IoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold BarIoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold Bar
Vikram Nandini
 
Linux File Trees and Commands
Linux File Trees and CommandsLinux File Trees and Commands
Linux File Trees and Commands
Vikram Nandini
 
Introduction to Linux & Basic Commands
Introduction to Linux & Basic CommandsIntroduction to Linux & Basic Commands
Introduction to Linux & Basic Commands
Vikram Nandini
 
Manufacturing - II Part
Manufacturing - II PartManufacturing - II Part
Manufacturing - II Part
Vikram Nandini
 
Prototyping Online Components
Prototyping Online ComponentsPrototyping Online Components
Prototyping Online Components
Vikram Nandini
 
Artificial Neural Networks
Artificial Neural NetworksArtificial Neural Networks
Artificial Neural Networks
Vikram Nandini
 
Design Principles for Connected Devices
Design Principles for Connected DevicesDesign Principles for Connected Devices
Design Principles for Connected Devices
Vikram Nandini
 
Communication in the IoT
Communication in the IoTCommunication in the IoT
Communication in the IoT
Vikram Nandini
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber Security
Vikram Nandini
 
cloud computing UNIT-2.pdf
cloud computing UNIT-2.pdfcloud computing UNIT-2.pdf
cloud computing UNIT-2.pdf
Vikram Nandini
 
Introduction to Web Technologies
Introduction to Web TechnologiesIntroduction to Web Technologies
Introduction to Web Technologies
Vikram Nandini
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Vikram Nandini
 
Ad

Recently uploaded (20)

Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18How to Create a Rainbow Man Effect in Odoo 18
How to Create a Rainbow Man Effect in Odoo 18
Celine George
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 

Programming in python Unit-1 Part-1

  • 2. content • Introduction to python • Installation of Python in windows • Running Python • Arithmetic operators • Values and types • Formal and Natural languages
  • 3. Introduction to Python • Dynamic interoperated language that allows both functional and object oriented programming languages • Interpreter • Python is a language • Simple • On all platforms • Real programming language • High level problems • Can split into modules • GUI can be done • It is a interpreter language • Very short compare with other languages • Indents will be used instead of brackets • After the bbc shows monty python cant do anything on reptiles
  • 7. Running a python • Start • Select python • In the prompt type the statement Print (“hello world”)
  • 8. Arithmetic operations • In the prompt of the python type • 3+4 • 3-4 • ¾ • 3%4 • 3*4 • Type with variables also • A=3 • B=5, etc.
  • 9. Values and types • Python numbers • Integer • 2,4,5 • Float • 2.3,4.5,7.8 • Complex • 3+5J • Python lists • can be any • [3, 4, 5, 6, 7, 9] • ['m', 4, 4, 'nani'] • Slicing operator, list index starts from zero • A[4],a[:2],a[1:2] • mutable • Python tuples () • Cannot change, slicing can be done a[4]. • immutable
  • 10. Values and types • Python Strings • Sequence of Characters • Single line • Ex. s='zaaaa nani' • Multi line • Ex. s='''zaaaa nani • print(s) • nani''' • print (s) • Sliicing can be done • Ex. S[5]
  • 11. Values and types • Python sets • Collection of unordered elements, elements will not be in order • S={3,4,5.6,’g’,8} • Can do intersection (&), union(|), difference (-), ^ etc. • Ex. A&b, a|b, a-b, a^b’ • Remove duplicates • {5,5,5,7,88,8,88} • No slicing can be done, because elements are not in order. • Python dictionaries
  • 12. Python dictionaries • Python dictionary is an unordered collection of items. • While other compound data types have only value as an element, a dictionary has a key: value pair. • Dictionaries are optimized to retrieve values when the key is known. • Creating a dictionary is as simple as placing items inside curly braces {} separated by comma. • An item has a key and the corresponding value expressed as a pair, key: value. • While values can be of any data type and can repeat, keys must be of immutable type (string, number or tuple with immutable elements) and must be unique.
  • 13. Python dictionaries (creating) 1.# empty dictionary 2.my_dict = {} 4.# dictionary with integer keys 5.my_dict = {1: 'apple', 2: 'ball'} 7.# dictionary with mixed keys 8.my_dict = {'name': 'John', 1: [2, 4, 3]} 10.# using dict() 11.my_dict = dict({1:'apple', 2:'ball'}) 13.# from sequence having each item as a pair 14.my_dict = dict([(1,'apple'), (2,'ball')])
  • 14. Python dictionaries (accesing) • my_dict = {'name':'Jack', 'age': 26} • # Output: Jack • print(my_dict['name’]) • # Output: 26 • print(my_dict.get('age’)) • # Trying to access keys which doesn't exist throws error# my_dict.get('address’) • # my_dict['address’] • Key in square brackets/get(), if you use get(), instead of error , none will be displayed.
  • 15. Change/ add elements in a dictionaries • my_dict = {'name':'Jack', 'age': 26} • # update value • my_dict['age'] = 27 • #Output: {'age': 27, 'name': 'Jack’} • print(my_dict) • # add item • my_dict['address'] = 'Downtown’ • # Output: {'address': 'Downtown', 'age': 27, 'name': 'Jack'}print(my_dict) • Mutable, if key is there: value will be updated, if not created new one.
  • 16. How to remove or delete the item in dictionaries • We can remove a particular item in a dictionary by using the method pop(). This method removes as item with the provided key and returns the value. • The method, popitem() can be used to remove and return an arbitrary item (key, value) form the dictionary. All the items can be removed at once using the clear() method. • We can also use the del keyword to remove individual items or the entire dictionary itself.
  • 17. How to remove or delete the item in dictionaries • # create a dictionary squares = {1:1, 2:4, 3:9, 4:16, 5:25} • # remove a particular item # Output: 16 • print(squares.pop(4)) # Output: {1: 1, 2: 4, 3: 9, 5: 25}print(squares) • # remove an arbitrary item • # Output: (1, 1) print(squares.popitem()) # Output: {2: 4, 3: 9, 5: 25} print(squares) • # delete a particular item • del squares[5] # Output: {2: 4, 3: 9}print(squares) • # remove all items • squares.clear() • # Output: {} • print(squares) • # delete the dictionary itself • del squares • # Throws Error# print(squares)
  • 20. Nested Dictionary • In Python, a nested dictionary is a dictionary inside a dictionary. • It's a collection of dictionaries into one single dictionary. Example: nested_dict = { 'dictA': {'key_1': 'value_1’}, 'dictB': {'key_2': 'value_2'}} • Here, the nested_dict is a nested dictionary with the dictionary dictA and dictB. • They are two dictionary each having own key and value.
  • 21. Nested dictionaries Example: >>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'}, 2: {'name': 'Marie', 'age': '22', 'sex': 'Female’}} >>print(people) #Accessing elements >>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'}, 2: {'name': 'Marie', 'age': '22', 'sex': 'Female’}} >>print(people[1]['name’]) >>print(people[1]['age’]) >>print(people[1]['sex'])
  • 22. Add or updated the nested dictionaries >>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'}, 2: {'name': 'Marie', 'age': '22', 'sex': 'Female’}} >>people[3] = {} >>people[3]['name'] = 'Luna’ >>people[3]['age'] = '24’ >>people[3]['sex'] = 'Female’ >>people[3]['married'] = 'No’ >>print(people[3])
  • 23. Add another dictionary >>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'}, 2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}, 3: {'name': 'Luna', 'age': '24', 'sex': 'Female', 'married': 'No’}} >>people[4] = {'name': 'Peter', 'age': '29', 'sex': 'Male', 'married’: 'Yes’} >>print(people[4]);
  • 24. Delete elements from the dictionaries >>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'}, 2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}, 3: {'name': 'Luna', 'age': '24', 'sex': 'Female', 'married': 'No'}, 4: {'name': 'Peter', 'age': '29', 'sex': 'Male', 'married': 'Yes’}} >>del people[3]['married’] >>del people[4]['married’] >>print(people[3]) >>print(people[4])
  • 25. How to delete the dictionary >>people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'}, 2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}, 3: {'name': 'Luna', 'age': '24', 'sex': 'Female'}, 4: {'name': 'Peter', 'age': '29', 'sex': 'Male’}} >>del people[3], people[4] >>print(people)
  • 26. Natural Language and Formal Language • The languages used by the humans called as a natural languages • Examples: English, French, Telugu,etc. • The languages designed and developed by the humans to communicate with the machines is called as the formal languages. • Example: C, C++, Java, Python, etc.
  • 27. Summary • Introduction to python • Installation of Python in windows • Running Python • Arithmetic operators • Values and types • Formal and Natural languages
  • 28. Any questions • [email protected] www.vikramneerugatti.com