WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
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
26 changes: 26 additions & 0 deletions InnekePuspitasari/List_Comprehensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
numbers = [10,20,30]
result = [n * 10 for n in numbers]

print(result)

#Equivalence vs Identity
# == for equality
a = [1,2,3]
b= a

print (a == b)
print(a is b)

#is for identity
a = [1,2,3]
b = [1,2,3]

print(a == b)
print(a is b)







8 changes: 8 additions & 0 deletions InnekePuspitasari/OOP1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class employee :
empCount = 0

def employee(self):
print("Total employee %d" % employee.empCount)

def __init__(self, name, salary):
print("con")
14 changes: 14 additions & 0 deletions InnekePuspitasari/Overloading.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class K:
def __init__(self, k):
self.k = k

# adding two objects
def __add__(self, o):
return self.k + o.k
ob1 = K(1)
ob2 = K(2)
ob3 = K("Geeks")
ob4 = K("For")

print(ob1 + ob2)
print(ob3 + ob4)
18 changes: 18 additions & 0 deletions InnekePuspitasari/class_computer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class computer:

def __init__(self):
self.__maxprice = 900
def sell (self):
print("selling Price: {}".format(self.__maxprice))
def setMaxprice(self, price):
self.__maxprice = price

c = computer()
c.sell()

#change the price
c.__maxprice=1000
c.sell()

c.setMaxprice(1000)
c.sell()
14 changes: 14 additions & 0 deletions InnekePuspitasari/dictionary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class OrangCantik :
def __init__(__args__):
pass


plants = {}
plants["durian"] = 10
plants["rambutan"] = 30
plants[1] = "rambutan"

faisal = OrangCantik()
plants[faisal] = 1

print(plants)
28 changes: 28 additions & 0 deletions InnekePuspitasari/inheritence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#parent class
class flower:
def __init__(self):
print("flower is ready")

def whoisThis(self):
print("flower")

def color(self):
print("color is red")

#child class
class rose(flower):
def __init__(self):
#call super() fungtion
super().__init__()
print("rose is ready")

def whoisThis(self):
print("rose")

def smell(self):
print("smell nice")

lil = rose()
lil.whoisThis()
lil.color()
lil.smell()
13 changes: 13 additions & 0 deletions InnekePuspitasari/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
my_list = []

my_list.append(1)
my_list.append(2)
my_list.append(3)

my_list.append(("yogi","imam"))

plants = {}
plants["pisang"] = 23
my_list.append(plants)

print(my_list)
14 changes: 14 additions & 0 deletions InnekePuspitasari/list_2D.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
list2d = []
list2d.append([])
list2d.append([])

list2d[0].append(1)
list2d[0].append(2)

list2d[1].append(3)
list2d[1].append(4)

for y in list2d:
for x in y :
print(x, end=" ")
print()
3 changes: 3 additions & 0 deletions InnekePuspitasari/list_loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
students=["inneke","suci","dewi","dinda","zahra"]
for student in students:
print (student)
19 changes: 19 additions & 0 deletions InnekePuspitasari/list_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
students = ["keke"]
students.append("sari")
print(students)

students.insert(1, "Puspita")
print(students)

girl_students = ["inneke","suci","dewi","dinda","zahra"]
students.extend(girl_students[0:5])
print(students)

students.sort()
print(students)

students.reverse()
print(students)

students.remove("sari")
print(students)
17 changes: 17 additions & 0 deletions InnekePuspitasari/methodOOP.PY
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Employe:
empCount=0

def __init__(self, name, salary):
self.name = name
self.salary = salary
Employe.empCount +=1

def displayCount(self):
print("total Employe %d" % Employe.empCount)

def displayEmploye(self):
print("name : ", self.name, ", salary : ", self.salary)

emp = Employe("NANI", 200)
emp.displayCount()
Employe.empCount
22 changes: 22 additions & 0 deletions InnekePuspitasari/oop_exampl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Employee:
empCount = 0

def Employee(self):
print("Total Employee %d" % Employee.empCount)

def __init__(self, name, salary):
print("constructor created")
self.name = name
self.salary = salary
Employee.empCount += 1

def displayCount(self):
print("Total Employee %d" % Employee.empCount)

def displayEmployee(self):
print("Name : ", self.name, ", Salary: ", self.salary)

emp1 = Employee("kiki", 2000)
#emp1.Employee()
emp1.displayEmployee()
emp2 = Employee("riri", 5000)
27 changes: 27 additions & 0 deletions InnekePuspitasari/polymorph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Parrot:

def fly(self):
print("Parrot can fly")

def swim(self):
print("Parrot can't swim")

class Penguin:

def fly(self):
print("Penguin can't fly")

def swim(self):
print("Penguin can swim")

# common interface
def flying_test(bird):
bird.fly()

#instantiate objects
blu = Parrot()
peggy = Penguin()

# passing the object
flying_test(blu)
flying_test(peggy)
2 changes: 2 additions & 0 deletions InnekePuspitasari/tuple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
my_tuple = tuple(["box","blue"])
print(my_tuple)
2 changes: 2 additions & 0 deletions InnekePuspitasari/tuple_immutable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tuple = ('iguana','axolotl','snake')
tuple[0] = 'iguana'
5 changes: 5 additions & 0 deletions InnekePuspitasari/tuple_packUnpack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pair= ("iguana","axolotl")

(key, value) = pair
print(key)
print(value)
28 changes: 28 additions & 0 deletions kekek02/OOP
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#parent class
class flower:
def __init__(self):
print("flower is ready")

def whoisThis(self):
print("flower")

def color(self):
print("color is red")

#child class
class rose(flower):
def __init__(self):
#call super() fungtion
super().__init__()
print("rose is ready")

def whoisThis(self):
print("rose")

def smell(self):
print("smell nice")

lil = rose()
lil.whoisThis()
lil.color()
lil.smell()