Menu

Python Code Please Follow Question S Requirements Print Function Used Use Return Task 3 Ba Q43867011

PYTHON CODE

PLEASE FOLLOW THE QUESTION’S REQUIREMENTS!!!!!!!

NO PRINT FUNCTION CAN BE USED, ONLY CAN USERETURN

Task 3: Balanced brackets

Write a function, balanced brackets(string) that takes in astring made up of brackets, e.g ‘(’, ‘[’, ‘{’, ‘)’, ‘]’ and ‘}’.The function should return a Boolean representing whether or notthe string is balanced in regards to brackets. A string said to bebalanced if it had many opening brackets of a given type as it hasclosing brackets of that type and if no bracket is unmatched. Notethat closing bracket cannot overlap each other as in ’[(])’.

Input: a non-empty list of strings brackets that represents thebrackets stack you are checking.

Output: a Boolean, True if the brackets are balanced; otherwiseFalse.

Examples

a) Calling balanced brackets(‘([])()(())(){}’) will returnTrue.

b) Calling balanced brackets(‘()[] { } {’) will returnFalse.

c) Calling balanced brackets(‘()([])’) will return True.

d) Calling balanced brackets(‘()()[{()})]’) will returnFalse.

e) Calling balanced brackets(‘(([]()()){})’) will returnTrue.

Marks are given for the correct behavior of thedifferent functions: (a) 1 mark for correct loop condition. 2 marksfor correct answers.

Expert Answer


Answer to PYTHON CODE PLEASE FOLLOW THE QUESTION’S REQUIREMENTS !!!!!!! NO PRINT FUNCTION CAN BE USED, ONLY CAN USE RETURN Task 3:…

OR