0% found this document useful (0 votes)
9 views

Python Programs Assignment

The document lists programming assignments involving checking if a number or string is a palindrome, analyzing character statistics in a string, removing odd numbers from a list, finding frequencies of list elements, filtering lists by starting characters, summing list elements by ending value, checking for perfect and Armstrong numbers, generating the Fibonacci series, random number generation simulating a dice, finding the factorial of a number using a function, a menu to calculate areas of shapes using functions, a menu for arithmetic operations using functions, and displaying prime numbers in a range using functions.

Uploaded by

Hema Chaudhry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python Programs Assignment

The document lists programming assignments involving checking if a number or string is a palindrome, analyzing character statistics in a string, removing odd numbers from a list, finding frequencies of list elements, filtering lists by starting characters, summing list elements by ending value, checking for perfect and Armstrong numbers, generating the Fibonacci series, random number generation simulating a dice, finding the factorial of a number using a function, a menu to calculate areas of shapes using functions, a menu for arithmetic operations using functions, and displaying prime numbers in a range using functions.

Uploaded by

Hema Chaudhry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like