In this blog,am performing a radish survey by using strings.Considering myself as a greengrocer i have to find out the following objectives:
1.To find out which is the most popular radish variety
2.To find out which is the least popular
3.To check whether anyone voted twice in the survey
1.To find out which is the most popular radish variety
2.To find out which is the least popular
3.To check whether anyone voted twice in the survey
For finding out the popular radish variety we have to consider the survey that have been done and import them.The text file that is containing the survey has name,hypen and the name of the variety of radish. To split the data we use the split() function in python so that the data is divided,after the split function.
After splitting the votes,we have to inspect the votes that are carried out in the survey.To know the specific people who have voted for a particular radish variety.Counting votes for each radish variety is a bit time consuming ,you have to know all the names in advance and you have to loop through the file multiple times. You'll need a data structure where you can associate a radish variety with the number of counted for it.A dictionary will be preferable for it
In the above screen shot it is shown about the people who have particularly voted for "White Icicle"in the radish survey. To check whether anyone voted twice in the survey,you will need to make a list of names of everyone who has voted and each time you see a new name,check if its already in the list of names starting with an empty list of names.This is how the radish survey is done.
-
No comments:
Post a Comment