Professional Documents
Culture Documents
software engineering
1. Accept an integer from a user and convert the integer to a binary number using a stack.
(use python).
binarynum= “ “
while not a.isempty():
binarynum += str(a.pop())
return binarynum
open_brackets = ["[","{","("]
closed_brackets = ["]","}",")"]
def check(myStr):
stack = []
for i in myStr:
if i in open_brackets:
stack.append(i)
if len(stack) == 0:
return "parenthesis matches"
else:
return " parenthesis doesn’t match "