Saturday, 18 April 2020

python class __ or private class component



When any class component has a name starting with two underscores (__), it becomes private - this means that it can be accessed only from within the class.

python find length of stack

class Stack:
    def __init__(self):
        self.stackList = [1,2,3]

stackObject = Stack()
print(len(stackObject.stackList))

Python Stack as class



class Stack:    # defining the Stack class
    def __init__(self):    # defining the constructor function
        print("Hi!")

stackObject = Stack()    # instantiating the object

Python Stack push() pop()



stack = []

def push(val):
    stack.append(val)


def pop():
    val = stack[-1]
    del stack[-1]
    return val

push(3)
push(2)
push(1)

print(pop())
print(pop())
print(pop())

Thursday, 16 April 2020

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...