Assignment 2 - Programs based on Revision Tour 1 & 2
1. Write a program to show entered string is a palindrome or not.
2. Write a program to show statistics of characters in the given line(to counts
the number of alphabets ,digits, uppercase, lowercase, spaces and other
characters).
3. WAP to remove all odd numbers from the given list..
4. Write a program to display frequencies of all the element of a list.
5. Write a program to display those string which are starting with ‘A’ from the
given list.
6. Write a program to find and display the sum of all the values which are
ending with 3 from a list.
7. Write a program to find whether an inputted number is perfect or not.
8. Write a Program to check if the entered number is Armstrong or not.
9. Write a program in Python to find Fibonacci series for given number
10 Write a Python program for random number generation that generates
random numbers between 1 to 6 (simulates a dice).
Solution
import random
n = random.randrange(1,10)
guess = int(input("Enter any number: "))
while n!= guess:
if guess < n:
print("Too low")
guess = int(input("Enter number again: "))
elif guess > n:
print("Too high!")
guess = int(input("Enter number again: "))
else:
break
print("you guessed it right!!")
Programs Based on Functions
11. Write a program in Python to find factorial for the given number using user
defined function
12. Write a Menu driven program to find the area of Circle, Rectangle and
Triangle using function
13. Writer a Menu Driven program to perform arithmetic operations((+,-,*, /,%)
using functions
14. Write a program to display the prime no’s in a given range using functions.