This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = raw_input("Enter a text ") | |
textsplit = text.split() | |
print "The word count is = ",len(textsplit) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is the code for the question in the page | |
#http://pylearn.pbworks.com/Print-Parameters | |
import sys | |
for arg in sys.argv: | |
print arg | |
if len(sys.argv)-1: | |
print "The number of command line arguments are: ",len(sys.argv)-1 | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is the code for the question in the page | |
#http://pylearn.pbworks.com/Count-Sentences | |
import sys | |
doc = open(sys.argv[1],'r') | |
text = doc.read() | |
linesplit = text.split('.') | |
print "the number of sentences are:",len(linesplit)-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is the code for the question in the page | |
#http://pylearn.pbworks.com/Count-Lines | |
import sys | |
doc = open(sys.argv[1],'r') | |
count = 0 | |
for line in doc: | |
count += 1 | |
print "the number of lines are: ",count |