0% found this document useful (0 votes)
7 views6 pages

Python Notes

The document outlines various Python programming concepts including mapping data types like dictionaries, list methods, exception handling, file handling, and third-party modules such as Pandas. It also covers object-oriented programming principles, code architecture styles (Pascal, Camel, Snake case), and provides examples of class methods and overloaded functions. Additionally, it includes tasks related to converting Excel files to CSV and validating email formats.

Uploaded by

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

Python Notes

The document outlines various Python programming concepts including mapping data types like dictionaries, list methods, exception handling, file handling, and third-party modules such as Pandas. It also covers object-oriented programming principles, code architecture styles (Pascal, Camel, Snake case), and provides examples of class methods and overloaded functions. Additionally, it includes tasks related to converting Excel files to CSV and validating email formats.

Uploaded by

akshat1aps
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Mapping Data Type

 Dictionary
It provides all functionality for mapping data types in
python.

o List Methods

1. append()
It adds element to the end of the list.

2. remove()
It removes first occurrence of element from a list.

3. index()
Return the sequence of first occurring object.

4. copy()
It duplicates the list with all the changes.

5. deepcopy()
It duplicates a list at a different address.
It is a function of copy module.

6. reverse()
It reverse the list.

7. clear()
It removes all the element from the list.

8. extend()
It individualy adds the elemnts of data type to the end of
the list.

9. insert(index,value)
It inserts the elements at any desired index of the list.

10.
Exception Handling

1. try
It is the function

Example:

try:
print(a/b)
except:

File Handling

Installing and Working on Third Party Module

1. Pandas
In Excel there are three columns name, roll no. and marks.
Make 10 entries in it.
Questions

[Link] an Excel File to CSV with 3 columns (Roll no.,


Name and Marks) and then read the CSV file using pandas
and display the details of failed students.

[Link] validate the Format of the Email Id entered by the user.

THIRD PARTY MODULES are released by other groups they


can either be paid or free.

OBJECT ORIENTED PROGRAMING

Memory Efficiency is increased.


Time Complexity is reduced.
Pep8 architecture is used in Python. It is a architecture
released by [Link] tells how to write code correctly.

Several Cases are used in Python scripting for the ease of


covinience and to read things fast and accurate.

1. Pascal Case
ArithmeticCalculator
2. Camal Case
arithmeticCalculator
[Link] Case
arithmetic_calculator

Method( ) = Function( )
Method is a function specific to class.

Attributes = Variables

def function(self): #self is a by default attribute

Example –---

class ArithmeticCalculatier:

def add(self,x,y):
return x+y

def diffrence(self,x,y):
return abs(x-y)

def multiply(self,x,y):
return x*y

def divide(self,x,y):
return x/y

def exponent(self,x,y):
return x**y

def int_division(self,x,y):
return x+y
a1=ArithmeticCalculatier()

x=[Link](1,2)
print(x)

#WAP an Object-Oriented Program in Python to Convert


Decimal to binary and then count 1s in the number. Check if
that is even or odd.

class decTobinary:
def to_binary(self,n):
if n<0:
print("Only non-negative integers are
supported")
if n==0:
return "0"
bits=[]
while n:
[Link](str(n%2))
n//=2
return "".join(reversed(bits))

def check_even_odd(self,n):
r=str(n)
c=0
for i in r:
if i=='1':
c+=1
if c%2==0:
print(f"The count of 1 is even that is
{c}")
else:
print(f"The count of 1 is odd that is {c}")

b1=decTobinary()
x=b1.to_binary(456)
print(x)

b1.check_even_odd(x)
Overloaded Function

Overloaded Functions are those functions which can handle


variable number of arguments. Example- print(“ ”)
We can also create overloaded function.

Example—

def product(*args)
res=1
for data in args:
res*=data
return res

product(2,5,3,2,5)

You might also like