AI

An elementary Python data compression question

General — Posted by aisci @ 20:21

Hi all,
Though I don't work in data compression, but for learning purpose only I ran a program very similar to the one given in version specific tutorial from www.python.org.  (ch 11, tut.pdf). The two programs are:

PROGRAM 1

import zlib
s = "witch which has which witches wrist watch"
print "Original String is ::%s:: and length of the string is ::%d::" %(s,len(s))
t = zlib.compress(s)
print "Compressed String is ::%s:: and length of the string is ::%d::" %(t,len(t))
print "Decompressed String is ::%s:: and length of the decompressed string is ::%d::" %(zlib.decompress(t),len(zlib.decompress(t)))

PROGRAM 2

import zlib
s = "witch which has which witches wrist watch"
print "Original String is ::%s:: and length of the string is ::%d::" %(s,len(s))
t = zlib.compress(s)
print "Compressed String is ::%s:: and length of the string is ::%d::" %(t,len(t))
print "Decompressed String is ::%s:: and length of the decompressed string is ::%d::" %(zlib.decompress(t),len(zlib.decompress(t)))

Now the problem is that:
in program2, the 'len(t)', i.e. length of the compressed string is greater than length of the original string!!! In program 1, this 'apparent anomaly' doesn't occur, and this is the string used in the python.org tutorial.

Can anybody provide an explanation? At this point, I don't want to read a few hundred pages on data compression to find out the answer.

Thanks in advance,
Abhishek Pathak.


Check out those Python scritpts (new!)

General — Posted by aisci @ 22:38

Hi everybody,

I have uploade some of my early python scripts. Go to the album called 'Python scripts' to get more details.

Will write again soon,

Bye. 

 


Hello, check out a few AI and Robotics photos I have uploaded

General — Posted by aisci @ 14:09

Hi,

I have uploaded some images related to AI and Robotics. I may sometimes later on upload some of the images I used durin my R&D projects on Image Processing.

 

Till then, enjoy these, and leave some comments regarding how you liked the collection, and whether you would like to see more such stuff here.

 

Bye. 


Welcome to one and all

General — Posted by aisci @ 13:22

Hello everybody,

Welcome to all : This is a community to discuss all you need to discuss on Science, Artificial Intelligence, Computer Science, Engineering, Technology, and of course, Python.

Bye. 


Congratulations!

General — Posted by aisci @ 21:21
If you can read this post, it means that the registration process was successful and that you can start blogging

Powered by LifeType