subject

Define a recursive function named immutify; it is passed any data structure that contains int, str, tuple, list, set, frozenset, and dict values (including nested versions of any of these data structures as an argument). It returns an immutable equivalent data structure (one that could be used for values in a set or keys in a dict). The types int, str, and frozenset are already immutable. Convert a set to a frozenset; convert all the values in a tuple to be their immutable equivalents, in the same order); convert a list to a tuple (with immutable equivalents of its values, in the same order); convert a dict to tuple of 2-tuples (see the association tuple in question 2) but here with the 2-tuples sorted by the dict’s keys. If immutify ever encounters a value of another type (e. g., float) it should raise a TypeError exception.

The following call (with many mutable data structures)
Example 1:
immutify( {'b' : [1,2], 'a' : {'ab': {1,2}, 'aa' : (1,2)}} )
returns the immutable data structure
(('a', (('aa', (1, 2)), ('ab', frozenset({1, 2}, ('b', (1, 2)))
Example 2:
immutify( [{1,2}, {3,frozenset([4,5])}, {6,7}])
Returns
(frozenset({1, 2}), frozenset({3, frozenset({4, 5})}), frozenset({6, 7}))

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:40
For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. after converting to the postfix expression, the program should evaluate the expression from the postfix and display the result. what should you submit? write all the code in a single file and upload the .c file. compliance with rules: ucf golden rules apply towards this assignment and submission. assignment rules mentioned in syllabus, are also applied in this submission. the ta and instructor can call any students for explaining any part of the code in order to better assess your authorship and for further clarification if needed. problem: we as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). in computer's language, however, it is preferred to have the operators on the right side of the operands, ie. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix write a program that takes an "infix" expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % ( example infix expression: (7-3)/(2+2) postfix expression: 7 3 2 2 result: rubric: 1) if code does not compile in eustis server: 0. 2) checking the balance of the parenthesis: 2 points 3) incorrect postfix expression per test case: -2 points 4) correct postfix but incorrect evaluation per test case: -i points 5) handling single digit inputs: maximum 11 points 6) handling two-digit inputs: 100 percent (if pass all test cases)
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
Answers: 1
question
Computers and Technology, 23.06.2019 04:00
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
question
Computers and Technology, 23.06.2019 22:00
Take a critical look at three gui applications you have used—for example, a spreadsheet, a word-processing program, and a game. describe how well each conforms to the gui design guidelines listed in this chapter.
Answers: 3
You know the right answer?
Define a recursive function named immutify; it is passed any data structure that contains int, str,...
Questions
question
History, 05.07.2019 03:30