Grade IX Program List
1. Write a python program to accept input from user and check whether a number is
Armstrong or not
Solution:
number = int(input(“Enter the Number”))
temp = number
calc = 0
while number>0:
digit = number % 10
calc = calc + digit ** 3
number = number // 10
If temp==calc:
print(“Armstrong Number”)
else:
print(“Not Armstrong Number”)
2. Write a python program to accept input from user and generate the Fibonacci series
Solution:
user_input = int(input("Enter the Number"))
first = 0
second = 1
temp = 0
#print(first)
#print(second)
for i in range(1,user_input):
total = first + second
print(total)
first = second
second = total
3. Write a python program to accept input from user and check whether a person is
eligible to vote or not
Solution:
age = int(input("Enter the Age"))
if age>=18:
print("Eligible to Vote")
else:
print("Not Eligible to Vote")
4. Write a python program to accept input from user and generate the multiplication
table
Solution:
number = int(input("Enter the Number"))
for i in range(1,11):
print(f"{number} X {i} = {number*i}")
5. Write a python program to check whether a number is Palindrome or not
Solution:
number = input("Enter the Number")
if number==number[::-1]:
print("Palindrome Number")
else:
print("Not Palindrome Number")
6. Write a python program to accept input from the user and calculate area of square
Solution:
side = int(input("Enter the side of square"))
print("Area of Square:",{side * side})
7. Write a python program to accept 2 inputs from the user and swap 2 numbers without
using third variable
Solution:
a = int(input("Enter the Number"))
b = int(input("Enter the Number"))
print(a,b)
a=a+b
b=a-b
a=a-b
print(a,b)
8. Write a python program to accept input from the user and find factorial of the number
Solution:
number = int(input("Enter the Number"))
factorial_result = 1
for i in range(1,number+1):
factorial_result = factorial_result * i
print("Factorial Result",factorial_result)
9. Write a python program to accept input from the user and find sum of all digits
Solution:
number = int(input("Enter the Number"))
temp = 0
while number>0:
digit = number%10
temp = temp + digit
number = number // 10
print("Total Sum:",temp)
10. Write a python program to accept string from the user and calculate length of the
string (without function)
Solution:
string_value = input("Enter the String::")
token = 0
for i in string_value:
token = token + 1
print("Length of String:",token)
11. Write a python program to accept 2 integers from users and perform following
operations
a. Addition
b. Subtraction
c. Multiplication
d. Division
e. Exponent
Solution:
a = int(input("Enter the Number1::"))
b = int(input("Enter the Number2::"))
print("Addition:",a+b)
print("Substraction:",a-b)
print("Multiplication:",a*b)
print("Division:",a/b)
print("Exponent:",a**b)
12. Write a program to accept list from the user and print sum of all the elements
Solution:
list_1 = [56,65,33,67]
total = 0
for i in range(0,len(list_1)):
total = total + list_1[i]
print("Total",total)
13. Write a program to accept an input from user and print all odd numbers from 1 to user
input
Solution:
value = int(input("Enter the Number"))
for i in range(1,value+1):
if i%2!=0:
print(i)
14. Write a program to accept an input from user and reverse the accepted number
Solution:
value = input("Enter the Number")
print(value[::-1])
15. Write a program to accept a list from user and find sum of all elements and average
of all elements.
Solution:
list_1 = [56,65,33,67]
total = 0
for i in range(0,len(list_1)):
total = total + list_1[i]
print("Average:",total/len(list_1))