Can any body help me

S

satish

how to write script for these

1.Given a test file containing lines of words such as (abc, abb,
abd,abb, etc), write a script that prints, in order of frequency, how
many times each word appears in the file.

2.
Write a script running in an endless loop that pings an IP (specified
on the command line) periodically. If the IP goes down n times in a row

send one email message (to an address specified on the command line)
that
it's down (n is specified on the command line).
Once it's available again n times in a row send an email that it's back
up.
When a specific signal is sent to the script it sends and email saying
that
it is shutting down and then exits

thanx
satish
 
S

Sidd

1.Given a test file containing lines of words such as (abc, abb,
abd,abb, etc), write a script that prints, in order of frequency, how
many times each word appears in the file.

Use dictionary datastructure in python and simple if-else statement.
Its simple give it a try.
 
F

Fredrik Lundh

Sidd said:
1.Given a test file containing lines of words such as (abc, abb,
abd,abb, etc), write a script that prints, in order of frequency, how
many times each word appears in the file.

Use dictionary datastructure in python and simple if-else statement.
Its simple give it a try.

so what are you waiting for? ;-)

(don't you think asking a mailing list for help with homework might be
considered cheating?

asking for help in figuring out why your attempt doesn't work might be
okay, but asking someone else to write the code for you is a bit, well...

I suggest starting out by looking at the relevant sections in the
tutorial; dictionaries are discussed in the "data structures" chapter,
and how to read stuff from files is discussed in the "input and output
chapter". you can find the tutorial here:

http://docs.python.org/tut/

)

</F>
 
T

Tim Chase

1.Given a test file containing lines of words such as (abc, abb,
abd,abb, etc), write a script that prints, in order of frequency, how
many times each word appears in the file.

solution 1) search the list archives...within the last week,
someone wanted to count unique lines in an input file. Several
solutions were given--one of which solved it by counting
instances of each unique line using a set. The resulting
dictionary can then be sorted (by key or value) to yield your
desired results. Tweak accordingly.

solution 2) using common *nix shell commands:

bash$ sort in.txt | uniq -c | sort -nr

-tkc
 
G

gene tani

satish said:
how to write script for these

1.Given a test file containing lines of words such as (abc, abb,
abd,abb, etc), write a script that prints, in order of frequency, how
many times each word appears in the file.

2.
Write a script running in an endless loop that pings an IP (specified
on the command line) periodically. If the IP goes down n times in a row

1. #include "We won't do your homework" and "don't you think your prof
reads the list?"
2. #include link about asking smart questions
3. don't know where you are in your python learning, but all the code
you need is in the online Python cookbook somewhere (search "ping IP
address" and "heartbeat"
http://aspn.activestate.com/ASPN/Cookbook/Python
 
J

John Salerno

Fredrik said:
so what are you waiting for? ;-)

(don't you think asking a mailing list for help with homework might be
considered cheating?

I don't mind when people post their homework assignments, because it
gives me some little projects to work on. :)

(On my own, of course!)
 
Joined
Nov 11, 2006
Messages
1
Reaction score
0
This is a test google gives out prior to an interview. I guess he didn't get the job.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top