473,543 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can any body help me

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

May 26 '06 #1
7 1112
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.

May 26 '06 #2
Sidd wrote:
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>

May 26 '06 #3
1. read this:
www.catb.org/~esr/faqs/smart-questions.html

2. do the Python tutorial

3. do your homework

4. when stuck, post your code here

HTH

May 26 '06 #4
satish a écrit :
how to write script for these
(snip homework specifications)

- read this:
http://www.catb.org/~esr/faqs/smart-questions.html
- browse the Python documentation
- do the tutorial if needed
- open you favorite code editor
- do your homework

If you're stuck, then post your code here.
thanx


HTH
May 26 '06 #5
> 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...with in 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


May 26 '06 #6

satish wrote:
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

May 26 '06 #7
Fredrik Lundh wrote:
Sidd wrote:
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?


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!)
May 26 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2111
by: Gordon - Adelphia | last post by:
I have a question regarding xhtml. Why, why, why does the ELEMENT <body> allow “unblocked” text. HTML does not (though, most browsers will render). Xhtml (transitional) however allows text nodes (PCDATA). All of HTML 4, xhtml – transitional, and xhtml-strict allow <div> to contain “unblocked” text. Does anybody know why – I’m looking for the...
7
3226
by: Tony Johansson | last post by:
Hello!! Assume I have a handle body pattern with classes called Handle and Body. In the Body class I store one int value for example 7 or some other integer value. In the Handle class I have a pointer to the Body class. If a want to create a STL container of List with the following declaration List <Handle <Body> > list
0
2158
by: Tony Johansson | last post by:
Hello! Here I have two classes these are called Handle and Body and a main. You have the class definition below. Some basic information. In the Handle class is there a pointer to the Body. Each Body object contains one primitive datatype int. The Body instance is created in the constructor for Handle. In main I instansiate some Handle...
4
1843
by: sadieslc | last post by:
I'm working on a PHP script, and the info from the form shows up in the headers of the email that I receive, but it doesn't show up in the body of the email. Can you please help me figure out what I'm doing wrong? Here is the script: <? function send_mail($emailaddress, $fromaddress, $emailsubject, $body) { $eol="\r\n"; ...
0
7412
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4900
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3395
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1830
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
979
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.