Python Programs – Class 11 Basics
1. Print all characters in a string
text = "Informatics Practices"
for char in text:
print(char)
2. Accept city and display monument
city = input("Enter a city name: ").strip().lower()
monuments = {
"agra": "Taj Mahal",
"delhi": "Red Fort",
"mumbai": "Gateway of India",
"jaipur": "Hawa Mahal"
}
if city in monuments:
print("Famous Monument:", monuments[city])
else:
print("Monument information not available.")
3. Convert inches to centimeters
inches = float(input("Enter length in inches: "))
cm = inches * 2.54
print("Length in centimeters:", cm)
4. EMI Calculator
amount = float(input("Enter loan amount: "))
rate = float(input("Enter annual interest rate (%): "))
time = float(input("Enter loan period (years): "))
interest = (amount * rate * time) / 100
total_amount = amount + interest
emi = total_amount / (time * 12)
print("Monthly EMI is:", round(emi, 2))
5. Remove duplicates from a list
elements = input("Enter list elements separated by space: ").split()
unique_elements = list(set(elements))
print("List after removing duplicates:", unique_elements)
6. Product of digits of a number
num = int(input("Enter a number: "))
product = 1
while num > 0:
digit = num % 10
product *= digit
num //= 10
print("Product of digits is:", product)
7. Print series: 2, 22, 222, ...
n = int(input("Enter number of terms: "))
term = ""
for i in range(1, n + 1):
term += "2"
print(term)
8. Check Palindrome Number
num = input("Enter a number: ")
if num == num[::-1]:
print("Palindrome Number")
else:
print("Not a Palindrome")
9. Words starting with given alphabet
sentence = input("Enter a sentence: ")
start_letter = input("Enter starting alphabet: ")
words = sentence.split()
print("Words starting with", start_letter, "are:")
for word in words:
if word.lower().startswith(start_letter.lower()):
print(word)
10. Random Number Guessing Game
import random
secret = random.randint(1, 10)
guess = 0
print("Guess the number between 1 and 10")
while guess != secret:
guess = int(input("Enter your guess: "))
if guess < secret:
print("Too low! Try again.")
elif guess > secret:
print("Too high! Try again.")
else:
print("Correct! You guessed the number.")
11. Add odd numbers to a new list from user input
numbers = []
odds = []
print("Enter 10 numbers:")
for i in range(10):
num = int(input())
numbers.append(num)
if num % 2 != 0:
odds.append(num)
print("Odd numbers list:", odds)
12. Find largest and smallest number from a list
numbers = list(map(int, input("Enter numbers separated by space: ").split()))
print("Largest number is:", max(numbers))
print("Smallest number is:", min(numbers))
13. Sum of squares of first 100 natural numbers
sum_of_squares = 0
for i in range(1, 101):
sum_of_squares += i ** 2
print("Sum of squares is:", sum_of_squares)
14. Print first 'n' multiples of a number
num = int(input("Enter a number: "))
n = int(input("Enter how many multiples: "))
for i in range(1, n + 1):
print(num * i)
15. Employee record operations
EmpRecord = ['Raajiv','40191692',[56500,98000,99000,72500,69600]]
# a) Average salary
avg_salary = sum(EmpRecord[2]) / len(EmpRecord[2])
print("Average Salary:", avg_salary)
# b) Salary in fifth month
print("Salary in 5th month:", EmpRecord[2][4])
# c) Maximum salary
print("Maximum Salary:", max(EmpRecord[2]))
# d) Emp Id
print("Emp ID:", EmpRecord[1])
# e) Change name from 'Raajiv' to 'Roshini'
EmpRecord[0] = 'Roshini'
print("Updated Record:", EmpRecord)