M.R.L. SR. SEC.
SCHOOL
NAME: HIMANSHI SHARMA
CLASS: 11TH
SECTION: A
SUBJECT: PRACTICAL FILE (PYTHON)
SUBMITTED TO: SUBMITTED BY:
Mr. Vishal Ms. Himanshi
Index
S.no. Program Remark
1 Write a program to enter two numbers and
find the greater one.
2 Write a program to enter three numbers and
find the greatest one.
3 Write a program to enter any number and print
its table.
4 Write a program to enter any number and print
its factorial.
5 Write a program to check if the entered
number is a palindrome or not.
6 Write a program to print the Fibonacci series:
0, 1, 1, 2, 3, 5, 8, 1, 3, 2, 1
7 Write a program to enter a string and check if it
is a palindrome or not.
8 Write a program to enter a list and print the
sum of the alternate element.
9 Write a program to enter a list, add 5 to all
even elements, add 10 to all odd elements, and
display the elements of the list.
10 Write a program to enter a list, swap the first
half of the list with the second half of the list
and also display the width.
Programs
1. Write a program to enter two numbers and find the greater one.
Code:
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
if a > b:
print("The greater number is:", a)
else:
print("The greater number is:", b)
Output:
2. Write a program to enter three numbers and find the greatest one.
Code:
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
c = int(input("Enter the third number: "))
if a > b and a > c:
print("The greatest number is:", a)
elif b > c:
print("The greatest number is:", b)
else:
print("The greatest number is:", c)
Output:
3. Write a program to enter any number and print its table.
Code:
num = int(input("Enter a number: "))
print("Multiplication table for", num, ":")
for i in range(1, 11):
print(num, "x", i, "=", num * i)
Output:
4. Write a program to enter any number and print its factorial.
Code:
num = int(input("Enter a number: "))
factorial = 1
for i in range(1, num + 1):
factorial *= i
print("The factorial of", num, "is:", factorial)
Output:
5. Write a program to check if the entered number is a palindrome or not.
Code:
num = input("Enter a number: ")
reversed_num = ""
index = len(num) - 1
while index >= 0:
reversed_num += num[index]
index -= 1
if num == reversed_num:
print("The number is a palindrome.")
else:
print("The number is not a palindrome.")
Output:
6. Write a program to print the Fibonacci series:
0, 1, 1, 2, 3, 5, 8, 1, 3, 2, 1
Code:
n = int(input("Enter the number of terms: "))
a, b = 0, 1
print("Fibonacci series:")
for i in range(n):
print(a, end=" ")
a, b = b, a + b
print()
Output:
7. Write a program to enter a string and check if it is a palindrome or not.
Code:
string = input("Enter a string: ")
reversed_string = ""
for char in string:
reversed_string = char + reversed_string
if string == reversed_string:
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")
Output:
8. Write a program to enter a list and print the sum of the alternate
element.
Code:
x = eval(input("Enter any list: "))
y = len(x)
S=0
for i in range(y):
if i % 2 == 0:
S = S + x[i]
print("The sum of alternate elements is:", S)
Output:
9. Write a program to enter a list, add 5 to all even elements, add 10 to all
odd elements, and display the elements of the list.
Code:
x = eval(input("Enter any list: "))
y = len(x)
for i in range(y):
if x[i] % 2 == 0:
x[i] = x[i] + 5
else:
x[i] = x[i] + 10
print("Modified list:", x)
Output:
10. Write a program to enter a list, swap the first half of the list with the
second half of the list and also display the width.
Code:
x = eval(input("Enter any list: "))
y = len(x)
mid = y // 2
swapped_list = []
i = mid
while i < y:
swapped_list.append(x[i])
i += 1
i=0
while i < mid:
swapped_list.append(x[i])
i += 1
print("Swapped list:", swapped_list)
Output: