Skip to content

Instantly share code, notes, and snippets.

View Deep18-03's full-sized avatar
🏠
Working from home

Deep18-03

🏠
Working from home
View GitHub Profile
@Deep18-03
Deep18-03 / ATM.py
Created May 18, 2020 17:28
simple atm code
#ATM
def deposit():
amount=int(input("enter the amount you want to deposit"))
global balance
balance=balance+amount
def withdraw():
amount=int(input("enter the amount you want to withdraw"))
global balance
import random
def compare(player1,player2):
if player1==player2:
print(f"Draw the dice number is {player1}\n")
elif player1>player2:
print("player1 wins")
print(f"player1 number is: {player1} and player2 number is: {player2}")
global player1_wins
import random
while True:
print("This is a dice rolling program")
print("Press Enter to roll")
input()
Number=random.randint(1,6)
if Number==1:
print("[*************************]")
print(" ")
print(" o ")
class Employee:
no_of_leaves=5
def __init__(self,name,salary,role):
self.name=name
self.salary=salary
self.role=role
def printdetail(self):
return f"name is {self.name}.Salary is {self.salary}.Role is {self.role}"
class Employee:
no_of_leaves=5
def __init__(self,name,salary,role):
self.name=name
self.salary=salary
self.role=role
def printdetail(self):
return f"name is {self.name}.Salary is {self.salary}.Role is {self.role}"
#ATM
def deposit():
amount=int(input("enter the amount you want to deposit"))
global balance
balance=balance+amount
def withdraw():
amount=int(input("enter the amount you want to withdraw"))
global balance
class Employee:
no_of_leaves=9
def __init__(self,aname,asalary,arole):
self.name=aname
self.salary=asalary
self.role=arole
def printable(self):
return f"name:{self.name} salary:{self.salary} role:{self.role}"
@Deep18-03
Deep18-03 / class method as alternative constructor.py
Last active May 14, 2020 19:20
This class method is used when you have to take value from wordpad in form of deep-2323-slalr
class Employee:
no_of_leaves=9
def __init__(self,aname,asalary,arole):
self.name=aname
self.salary=asalary
self.role=arole
def printable(self):
return f"Name of the employeer is {self.name} and his work as a {self.role} and having salary {self.salary}"
@Deep18-03
Deep18-03 / class method.py
Last active May 13, 2020 13:56
simple class method example
class Employee:
no_of_leaves=8 #class variable
def __init__(self,aname,asalary,arole):
self.name=aname
self.salary=asalary
self.role=arole
def printable(self):
return f"Name is {self.name} and salary is {self.salary} and role is {self.role}"
#map,filter,reduce
#reduce
import functools
lst=[1,2,4,54,5,6]
num=functools.reduce(lambda x,y:x+y,lst)
print(num)