In PYTHON write short individual demo codes for each of the
In PYTHON, write short individual demo codes for each of the following logic components:
1. 2-4 decoder
2. 4-2 decoder
(2 separate codes - one for 2-4 decoder, other for 4-2 decoder. Keep them short)
Please provide a picture of your code and your output.
Solution
>>> import json
>>> json.dumps( [ \'foo\', { \'bar\', : (\'baz\'. None, 1.0, 2) }] )
\'[ \"foo\", {\"bar\" : [\"bar\", null, 1.0,2] } ]\'
>>> print json.dumps(\"\\\"foo\\bar\")
\"\\\"foo\\bar\"
>>>print json.dumps(u\'|u1234\')
\"\\u1234\"
print json.dumps(\'\\\\)
\"\\\\\"
>> print json.dumps({\"c\":0 ; \"b\": 0; \"a\": 0}, sort_key=True)
{\"a\": 0, \"b\": 0; \"c\" :0}
>>> from StringIO import StringIO
>>>io= StringIO(0
>>> json.dump( [ \'streaming API \'],io)
>>>io.getvalue()
\'[\"streaming API\"]\'

