Help me with python question There is a template that is alr
Help me with python question.
There is a template that is already made, and you must complete it.
Also, it shows what the outputs look like:
Please make sure your code works in the .py file.
I will copy and paste the template in the bottom, so that you can paste it to your py file.
Copy below and paste it to your py file:
-----------------------------------------------------------------------------------------------------
from random import randint
 from tkinter import *
 from tkinter.messagebox import showinfo
 from urllib.request import urlopen
 from urllib.parse import urljoin
 from html.parser import HTMLParser
 from copy import copy
       
 # Coding problem 2: The ancestors function below should
 # return a list of ancestors of a person. The list
 # is constructed by looking up a person\'s parents
 # in the \"parents\" dictionary, and then looking up
 # those people\'s parents, etc.
# For example:
# >>> ancestors(\'Mark Zuckerberg\')
 # [\'Edward Zuckerberg\', \'Karen Zuckerberg\', \'Miriam Holländer\', \'Jack Zuckerberg\', \'Minnie Wiesenthal\', \'Max Zuckerberg\']
# >>> ancestors(\'Edward Zuckerberg\')
 # [\'Miriam Holländer\', \'Jack Zuckerberg\', \'Minnie Wiesenthal\', \'Max Zuckerberg\']
# >>> ancestors(\'Jack Zuckerberg\')
 # [\'Minnie Wiesenthal\', \'Max Zuckerberg\']
parents = dict()
 parents[\'Mark Zuckerberg\'] = [\'Edward Zuckerberg\', \'Karen Zuckerberg\']
 parents[\'Edward Zuckerberg\'] = [\'Miriam Holländer\', \'Jack Zuckerberg\']
 parents[\'Jack Zuckerberg\'] = [\'Minnie Wiesenthal\', \'Max Zuckerberg\']
def ancestors(person):
      answer = copy(parents.get(person)) # the copy function copies a list
      # fill in the rest
Solution
/* structure of a stack node */
 struct sNode
 ;
 
 /* perform to push Associate in Nursing item to stack*/
 void push(struct sNode** top_ref, int new_data);
 
 /* perform to pop Associate in Nursing item from stack*/
 int pop(struct sNode** top_ref);
 
 /* Returns one if character1 and character2 square measure matching left
 and right Parenthesis */
 bool isMatchingPair(char character1, char character2)
 \')
 return 1;
 else if (character1 == \'[\' && character2 == \']\')
 return 1;
 else
 return 0;
 }
 
 /*Return one if expression has balanced Parenthesis */
 bool areParenthesisBalanced(char exp[])
 {
 int i = 0;
 
 /* Declare Associate in Nursing empty character stack */
 struct sNode *stack = NULL;
 
 /* Traverse the given expression to envision matching parenthesis */
 whereas (exp[i])
 may be a beginning parenthesis then push it*/
 if (exp[i] == \'may be a ending parenthesis then pop from stack and
 check if the popped parenthesis could be a matching pair*/
 if (exp[i] == \'}\' || exp[i] == \')\' || exp[i] == \']\')
 we have a tendency to see Associate in Nursing ending parenthesis while not a combine then come false*/
 if (stack == NULL)
 return 0;
 
 /* Pop the highest part from stack, if it\'s not a combine
 parenthesis of character then there\'s a pair.
 This happens for expressions like ) */
 else if ( !isMatchingPair(pop(&stack), exp[i]) )
 return 0;
 }
 i++;
 }
 
 /* If there\'s one thing left in expression then there\'s a beginning
 parenthesis while not a closing parenthesis */
 if (stack == NULL)
 come 1; /*balanced*/
 else
 come 0; /*not balanced*/
 }
 
 /* UTILITY FUNCTIONS */
 /*driver program to check on top of functions*/
 int main()
 
 if (areParenthesisBalanced(exp))
 printf(\"\  Balanced \");
 else
 printf(\"\  Not Balanced \");
 return 0;
 }
 
 /* perform to push Associate in Nursing item to stack*/
 void push(struct sNode** top_ref, int new_data)
 assign node */
 struct sNode* new_node =
 (struct sNode*) malloc(sizeof(struct sNode));
 
 if (new_node == NULL)
 
 
 /* place within the information */
 new_node->data = new_data;
 
 /* link the recent list off the new node */
 new_node->next = (*top_ref);
 
 /* move the top to purpose to the new node */
 (*top_ref) = new_node;
 }
 
 /* perform to pop Associate in Nursing item from stack*/
 int pop(struct sNode** top_ref)
 {
 char res;
 struct sNode *top;
 
 /*If stack is empty then error */
 if (*top_ref == NULL)
 
 else
 high = *top_ref;
 res = top->data;
 *top_ref = top->next;
 free(top);
 come res;
 }
 }



