CSE Skill Lab 2 Unit 1
CSE Skill Lab 2 Unit 1
CSE Skill Lab 2 Unit 1
PRACTICAL 1
PRIYANKA SURYAWANSHI
STUDY AND IMPLEMENT DATA
STRUCTURES IN PYTHON
INTRODUCTION
• The name Python was selected from the TV Show "The Complete Monty Python’s Circus",
which was broadcasted in BBC from 1969 to 1974.
• Guido developed Python language by taking almost all programming features from
different languages
1. Functional Programming Features from C
2. Object Oriented Programming Features from C++
3. Scripting Language Features from Perl and Shell Script
4. Modular Programming Features from Modula-3
• NOTE:
• Internally Google and Youtube
use Python coding
• NASA and Nework Stock
Exchange Applications developed
by Python.
• Top Software companies like
Google, Microsoft, IBM, Yahoo
using Python.
TOP COMPANIES USING PYTHON
FEATURES OF PYTHON
• General Purpose
• Dynamically typed
• Object Oriented
• High level
• Multilevel
• Interpretted
• Open Source
• Functional
• Procedural
FLAVORS OF PYTHON
PYTHON VERSIONS
• NOTE
• Python 3 won't provide backward compatibility to Python2
• i.e there is no guarantee that Python2 programs will run in Python3.
INSTALLATIONS
1) List []
2) Set {}
3) Tuples ()
4) Dict {key1:value1, key2:value2}
SIMPLE DATATYPES
a=10
type(a) c = 10+1.5j
type(c)
2) float
Note: Some built in functions
b=7.3
type(b) type() - To check the type of variable
id() - To get the address of object
print() - To print the value
• String data type
String slicing
• Bool data type
COMPLEX DATA TYPES
List []
• List is mutable
• Duplicate allowed
• Sequence maintained
• Multiple None types are allowed
• Add/delete/update/replace allowed
• Growable in nature
• Array data structure is used
set {}
• Set is Mutable
• Duplicates not allowed
• Sequence not maintained
• Single None type is allowed only
• Hash table data structure
• Growable in nature
• Index concept is not applicable
Tuple ( )
• Immutable
• Duplicated allowed
• Sequence allowed
• Many none types allowed
• Array data structure used
Dictionary { }
• {pair} -- key:value
• Mutable
• hashtable + DLL
• Key
duplicates not allowed
seq maintained
single NoneType Allowed
• Value
duplicates Allowed
multiple NoneType allowed
seq - no question - value comes with key… sequence as per key
WHAT IS A DATA STRUCTURE?
1. Write a program to display unique vowels present in the given word? (list)
2. Write a program to take a tuple of numbers from the keyboard and print its sum and
average?
4. Write a program to print different vowels present in the given word? (set)
5. Write a program to enter name and percentage marks in a dictionary and display
information on the screen
6. Write a program to take dictionary from the keyboard and print the sum of values?
7. Write a program to find number of occurrences of each letter present in the given string?
8. Write a program to accept student name and marks from the keyboard and creates a
dictionary. Also display student marks by taking student name as input?
9. Create a list by picking an odd index items from the first list and even index items from
the second
12. Create a Python set such that it shows the element from both lists in a pair
13. Find the intersection (common) of 2 sets and remove those elements from the first set.
14. Iterate a given list and check if a given element exists as a key’s value in a dictionary. If
not, delete it from the list.
15. Get all values from the dictionary and add them to a list but don’t add duplicates.