1. Engineering
  2. Computer Science
  3. python 3...

Question: python 3...

Question details

Python 3

Braces You are designing a compiler for a C++ program and need to check that braces in any given file are balanced Braces in a string are considered to be balanced if the following criteria are met · All braces must be closed. Braces come in pairs of the form。() and []. The left brace opens the pair, and the right one closes it. In any set of nested braces, the braces between any pair must be closed For example, [)l is a valid grouping of braces but K] is not. Function Description Complete the function braces in the editor below. The function must return an array of strings where the string at each index i denotes whether or not the braces were balanced in a values The array should consist of strings YES or NO aligned with their indexes in values. braces has the following parameterls): values/valueso...valuesp-: an array of strings to analyze Constraints .1sns15 . 1 s length of values, s 100 guaranteed that each values, consists of (. ). and l only. Input Format For Custom Testing Input from stdin will be processed as follows and passed to the function The first line contains an integer n, the number of elements in values. Each of the next n lines contains a string describing values, where 0 si<n

YOUR ANSWER For help on how to read input and write output in Python 3, click here. Click here to know more about handling STDIN and STDOUT in other languages Sample Problem Write a program that adds two numbers prints the sum to STDOUT. Read the input from STDIN. The first line of your input will contain an integer (N) that tells you how many more lines there are in the input. Each of the subsequent N lines contain 2 integers). You need to print the sum of each pair on a separate line of STDOUT Sample Input 1 5 3 10 999 -34343 Sample Output: 13 33344 SOLUTION CODE: n-int(input ) tor in range(n) a, b map(int, input).stripo.splito) print (a b

Draft saved 02:08 pm Original Coe yton 3 1 H#1 /bin/python3 10 11 # Complete the braces function below 12 def braces (values): 13 14Hİf name == main

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution