Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
55 views

1.write A Python Program To Count T

The document contains 5 Python programs: 1. A program to count the number of vowels in a user-input string. 2. A program to check for common letters between two user-input strings. 3. A program to check if a user-input string is a palindrome. 4. A program to swap the first and last elements of a user-input list. 5. A program to check if a user-input number is a strong number.

Uploaded by

Divya Sriju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

1.write A Python Program To Count T

The document contains 5 Python programs: 1. A program to count the number of vowels in a user-input string. 2. A program to check for common letters between two user-input strings. 3. A program to check if a user-input string is a palindrome. 4. A program to swap the first and last elements of a user-input list. 5. A program to check if a user-input number is a strong number.

Uploaded by

Divya Sriju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.Write a Python Program to Count the Number of Vowels in a String?

string=raw_input("Enter string:")
vowels=0
for i in string:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or
i=='O' or i=='U'):
vowels=vowels+1
print("Number of vowels are:")
print(vowels)

2.Write a Python Program to Check Common Letters in Two Input Strings?

s1=raw_input("Enter first string:")


s2=raw_input("Enter second string:")
a=list(set(s1)&set(s2))
print("The common letters are:")
for i in a:
print(i)

3.Write a Python Program to Check if a String is a Palindrome or Not?


string=raw_input("Enter string:")
if(string==string[::-1]):
print("The string is a palindrome")
else:
print("The string isn't a palindrome")

4.swap first and last in a list

a=[]
n= int(input("Enter the number of elements in list:"))
for x in range(0,n):
element=int(input("Enter element" + str(x+1) + ":"))
a.append(element)
print("original list is",a)
temp=a[0]
a[0]=a[n-1]
a[n-1]=temp
print("New list is:")
print(a)

5.Write a Python Program to Check if a Number is a Strong Number?


sum1=0
num=int(input("Enter a number:"))
temp=num
while(num):
i=1
f=1
r=num%10
while(i<=r):
f=f*i
i=i+1
sum1=sum1+f
num=num//10
if(sum1==temp):
print("The number is a strong number")
else:
print("The number is not a strong number")

You might also like