Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Built-In-Module/math_module.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import math as m
from mathmatics_operation import add,sub
from mathmatics_operation import Mathmatics as mt

print(f"Square Root: ",m.sqrt(25))
print("Ceil :",m.ceil(3.1))
print("Floor :", m.floor(3.9))
print("Factorial :", m.factorial(6))
print("Power :",m.pow(3,3))
print("Reminder:",m.remainder(10,3))
print("Addition",add(2,3))
print("Substraction",sub(5,3))
print("Addition",mt.add(2,3))
print("Substraction",mt.sub(5,3))
9 changes: 9 additions & 0 deletions Built-In-Module/math_module_builtin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import math

print("Calculate Power",math.pow(2,3))
print("Check Reminder",math.remainder(10,3))
print("Factorial of number",math.factorial(6))
print("Truncate decimal value",math.trunc(2.3))
#num="ser"
#print("Is number?",math.isnan(num))
print("Calculate Square Root",math.sqrt(25))
21 changes: 13 additions & 8 deletions Built-In-Module/mathmatics_operation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
def add (number1,number2):
return number1 + number2
class Mathmatics:
@staticmethod
def add (number1,number2):
return number1 + number2

def sub (number1,number2):
return number1 - number2
@staticmethod
def sub (number1,number2):
return number1 - number2

def div (number1,number2):
return number1 / number2
@staticmethod
def div (number1,number2):
return number1 / number2

def mul (number1,number2):
return number1 / number2
@staticmethod
def mul (number1,number2):
return number1 / number2

15 changes: 15 additions & 0 deletions Collection/dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable_name={
"name":"Subir",
"surname":"shah",
"address":"pune",
}
print(type(variable_name))
print(variable_name['name'],variable_name['surname'])
variable_name['name']="Avishek"
print(variable_name)
print(variable_name.keys())
print(variable_name.values())
print(variable_name.get("name"))
print(variable_name.items())

print(variable_name)
52 changes: 52 additions & 0 deletions Collection/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'''
string_list=["Subir","Gitanjali","Avishek","Subir"]
print(string_list)
print(string_list[1])
string_list[1]="Ranjiv"
print(string_list)
#check lenght of list
print(len(string_list))
print(type(string_list))

surname=["shah","varma","sharma"]
concati=string_list+surname
print(concati)

a=string_list.append(surname)
print(string_list)
print(string_list[3])
print(string_list[4][2])
print(string_list[1:4])

if "Avishek" in string_list:
print("Yes")
else:
print("Not Present")

if "shah" in string_list[4]:
print("Yes")
else:
print("Not Present")
'''

fruit=["Banana","Apple","Cherry","Papaya","Banana"]
print("Banana Occurance ",fruit.count("Banana"))
fruit.remove("Banana")
fruit.remove("Banana")
print("Remove Banana from list",fruit)
fruit.pop(1)
print("pop 1st element from list",fruit)
fruit.clear()
print("Clear list",fruit)
fruit=["Banana","Apple","Cherry","Papaya","Banana"]
fruit.reverse()
print("Reverse List :",fruit)
fruit.sort()
print("Sorting",fruit)

for f in fruit:
if f == "Apple":
print(f)

fruit.insert(1,"Watermelon")
print(fruit)
11 changes: 11 additions & 0 deletions Collection/set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from Collection.list import fruit

number={1,2,3,4,4}
print(number)
number.add(5)
print(number)
number.remove(5)
print(number)
fruit1= {"Banana","Apple","Papaya","Mango","Banana",1,2,3}
print(fruit1)
print(fruit1)
5 changes: 5 additions & 0 deletions Collection/tuple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fruit=("Banana","Apple","Papaya","Mango","Banana")
fruit1=("Banana","Apple","Papaya","Mango","Banana")

print(fruit)
print(fruit.count("Banana"))
19 changes: 19 additions & 0 deletions Exception_Handling/exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#number=10
#print(number/0)


try:
file_name=open("xvz.txt","w")
file_name.read()
except ZeroDivisionError as e:
print("Zero Division Error: {0}".format(e))
except ValueError as e:
print("Value Error Exception: {0}".format(e))
except FileNotFoundError as e:
print("File not Present Exception: {0}".format(e))
except Exception as e:
print("Unknown Error because: {0}".format(e))
finally:
file_name.close()

print("This is we have to print")
18 changes: 18 additions & 0 deletions Exception_Handling/user_defined.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ElectionError(Exception):
pass

def check_eligibility(age):
if int(age) > 18:
return True
else:
raise ElectionError("Person is not Eligible for creating election Card")

if __name__ == '__main__':
age=input("Enter your Age?")
try:
if check_eligibility(age):
print("Person is Eligible")
except Exception as e:
print(e)


4 changes: 4 additions & 0 deletions OOPs/Encapsulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def show_detail(self):


f=Mango("Mango","Yello","Summer","Hapus")
print(f.name)
print(f._color)
print(f.get_season())
print(f.type)
print(f.show_detail())


31 changes: 31 additions & 0 deletions ObjectOrientedProgrammin/Bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Bank:
def __init__(self):
self.branch_code = None
self.branch_name = None
self.branch_address = None
'''
def __init__(self,branch_code,branch_name, branch_address):
self.branch_code=branch_code
self.branch_name=branch_name
self.branch_address=branch_address
'''
def set_bank_information(self,branch_code,branch_name,branch_address):
self.branch_code = branch_code
self.branch_name = branch_name
self.branch_address = branch_address

def get_bank_information(self):
return self.branch_code,self.branch_name,self.branch_address


def get_bank_information():
return get_bank_information()

#sbi=Bank("SBIN1234","SBI FC Road","Sivaji Nagar, Pune")
sbi=Bank()
sbi.set_bank_information("SBIN1234","SBI FC Road","Sivaji Nagar, Pune")
#sbi.__init__("SBIN1234","SBI FC Road","Sivaji Nagar, Pune")
print(sbi.get_bank_information())
print("Branch Name : ",sbi.branch_name)


22 changes: 22 additions & 0 deletions ObjectOrientedProgrammin/abstraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from abc import abstractmethod,ABC

class Car(ABC):
@abstractmethod
def start(self):
pass

def engine(self):
print("Starting Engine")

class ElectricVehical(Car):
def start(self):
print("Starting Electric Vehicle")


'''def engine(self):
print("Starting Engine from Elctric Vehicle class")
'''

elctric=ElectricVehical()
#elctric.engine()
elctric.start()
6 changes: 6 additions & 0 deletions ObjectOrientedProgrammin/customer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from ObjectOrientedProgrammin import Bank
sbi=Bank()
sbi.set_bank_information("SBIN1234","SBI FC Road","Sivaji Nagar, Pune")
#sbi.__init__("SBIN1234","SBI FC Road","Sivaji Nagar, Pune")
print(sbi.get_bank_information())
print("Branch Name : ",sbi.branch_name)
34 changes: 34 additions & 0 deletions ObjectOrientedProgrammin/encapsulation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Bank:
def __init__(self,account_number,account_name,account_branch):
self._account_number=account_number #protected
self.__account_name=account_name #private
self.account_branch=account_branch

def get_account_number(self):
return self._account_number

def get_account_name(self):
return self.__account_name

def get_account_branch(self):
return self.account_branch

class Branch(Bank):
def __init__(self,account_number,account_name,account_branch,branch_address):
Bank.__init__(self,account_number,account_name,account_branch)
self.branch_address=branch_address

def get_branch_address(self):
return self.branch_address

def show_all_details(self):
return self._account_number,self.account_branch,self.branch_address,self.get_account_name()


branch=Branch("0000001","Ranjiv","Sambhajinagar","BaifRoad Pune")
print(branch._account_number)
#print(branch.get_account_name())
#print(branch.account_branch)
#print(branch.branch_address)

print(branch.show_all_details())
34 changes: 34 additions & 0 deletions ObjectOrientedProgrammin/multiple_inheritance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Honda:
def __init__(self,company_name,company_address):
self.company_name=company_name
self.company_address=company_address

def show_company_details(self):
return self.company_name,self.company_address

class HondaCar(Honda):
def __init__(self,company_name,company_address,car_name):
super().__init__(company_name,company_address)
self.car_name=car_name


class HondaBike():
def __init__(self, bike_name):
#super().__init__(company_name, company_address)
self.bike_name=bike_name


class HondaCustomer(HondaCar,HondaBike):
def __init__(self,company_name,company_address,car_name,bike_name,customer_name):
HondaCar.__init__(self,company_name,company_address,car_name)
HondaBike.__init__(self,bike_name)
self.customer_name=customer_name

def show_all_details(self):
return self.company_name,self.company_address,self.car_name,self.bike_name,self.customer_name


hc=HondaCustomer("Honda","Japanese","City Honda","CBZ","Ranjiv")
print(hc.show_all_details())


45 changes: 45 additions & 0 deletions ObjectOrientedProgrammin/polymorphism_method_overloading.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Car:
def start_engine(self):
print("Starting Engine of Car")

def drive(self):
print("This Car is Driving on Road")


class Electric(Car):
def start_engine(self):
print("Start Electric Car Engine")

def drive(self):
print("Driving Electric Car")

class SportsCar(Car):
def start_engine(self):
print("Start Sports Car Engine")

def drive(self):
print("Driving Sports Car")

#Run time polymorphism
def test_runtime(xyz):
xyz.start_engine()
xyz.drive()

car=Car()
electric=Electric()
sportscar=SportsCar()

test_runtime(car)
test_runtime(electric)
test_runtime(sportscar)

'''
electric.start_engine()
electric.drive()

sportscar.start_engine()
sportscar.drive()

car.start_engine()
car.drive()
'''
13 changes: 13 additions & 0 deletions ObjectOrientedProgrammin/polymorphism_method_overriding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Car:
def show_details(self,*args):
if (len(args) == 1):
print("One Arguments has been passed")
elif (len(args) == 2):
print("Two Arguments has been passed")
elif (len(args) == 3):
print("Three Arguments has been passed")

car=Car()
car.show_details("Hyundai")
car.show_details("Hyundai","Maruti")
car.show_details("Hyundai","Maruti","Wolkwagon")
Loading