Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lesson 9 hw
# Object Oriented Programming - Data Structure Stack ''' Stack - LIFO (Last In First Out) 1. Extracting book 4 Book 1 --->> Book 2 --->> Book 3 --->> Book 4 Book 4 Book 5 Book 5 Book 6 Book 6 2. Removing from pile of books (always the thing on top) (Popping) Book 4 --->> Book 3 Book 2 Book 1 3. Adding Book 5 to the pile (always on the top) (Pushing) Book 5 Book 4 Book 3 Book 2 Book 1 ''' class Stack: def __init__(self): self.items = [] # empty list def push(self, add_an_item): return self.items.append(add_an_item) def pop(self): if self.isEmpty() is True: return [] else: # stack not empty return self.items.pop() def show(self): print (self.items[:]) def isEmpty(self): if self.items == []: return True else: return False def size(self): return len(self.items) ''' Homework 1. Study thoroughly Stack class 2. Write an OOP for medical employees a. Doctor, Nurse b. Salaries for them c. Working hours for each of them d. Total number of employees working in the hospital '''
run
|
edit
|
history
|
help
0
IP Network & Broadcast Address Calculator 2
Lesson 8 updated
add through function
https://rextester.com/HYVN80193
E
Add missing person on list with default age 30
P
func mast
Convert String to Lower Case
Insertion sort