Sunday, 9 August 2015

Radish survey

Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.


A survey was conducted for a greengrocer to see what radish varieties customers prefer. We got 300 lines of survey data. Each line consists of a name, a hyphen then a radish variety.


Code to read the data line by line
Count all the votes


The problems associated with this data are:
The survey contains many unclean data. So we have to write a program to munge the data so that all the data looks the same. 

Cleaning data


Some of the votes have double space in between 1st and 2nd word. So 'replace' function is used to replace the double space with single space.


Replacing the double spaces

We have to check if someone has voted twice. Thus we have to make a list of the names of everyone who has voted. Each time a new name comes it will check whether its already exists or not.

To check fraudulence

After solving these problems, the winner can be  found
Winner




No comments:

Post a Comment