#This program checks whether a triangle is isoceless or equilateral or scalian
def triangletype(s1,s2,s3):
if s1=='' or s2=='' or s3=='':
print "I think you had forgotten to enter one side"
else:
if s1==s2 and s2==s3:
print "Triangle is equilateral"
elif s1==s2 or s2==s3 or s3==s1:
print "Trianlge is isocless"
else:
print "It is scalian"
s1=raw_input("Enter the length of side 1:")
s2=raw_input("Enter the length of side 2:")
s3=raw_input("Enter the length of side 3:")
triangletype(s1,s2,s3)
raw_input("")
Thursday, March 5, 2009
Find the Longest Word In A String
#Length of longest word in a String
import string
s=raw_input("Enter the String:")
a=string.split(s)
l_word=a[0]
l_length=a[0]
for i in range(0,len(a)):
if len(a[i])>len(l_word):
l_length=len(a[i])
l_word=a[i]
print "The longest word is ",l_word," with length:",l_length
import string
s=raw_input("Enter the String:")
a=string.split(s)
l_word=a[0]
l_length=a[0]
for i in range(0,len(a)):
if len(a[i])>len(l_word):
l_length=len(a[i])
l_word=a[i]
print "The longest word is ",l_word," with length:",l_length
Subscribe to:
Posts (Atom)