Python Practical File - Class 10
Experiment 1: Print Statement
Aim: To display a message on the screen.
Source Code:
print("Hello World")
Output:
Hello World
Result: Thus the program for print statement was executed successfully.
Experiment 2: Variables and Data Types
Aim: To learn variables and different data types in Python.
Source Code:
name = "Vipin"
age = 16
marks = 89.5
print(name)
print(age)
print(marks)
Output:
Vipin
16
89.5
Result: Thus the program for variables and data types was executed successfully.
Experiment 3: Addition of Two Numbers
Aim: To find the sum of two numbers.
Source Code:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print("Sum =", sum)
Output:
Enter first number: 10
Enter second number: 20
Sum = 30
Result: Thus the program for addition of two numbers was executed successfully.
Experiment 4: Even or Odd Number
Aim: To check whether a number is even or odd.
Source Code:
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")
Output:
Enter a number: 8
Even Number
Result: Thus the program for even or odd number was executed successfully.
Experiment 5: For Loop Program
Aim: To print numbers using a for loop.
Source Code:
for i in range(1, 6):
print(i)
Output:
1
2
3
4
5
Result: Thus the program for for loop program was executed successfully.
Experiment 6: Create and Display List
Aim: To create and print a list.
Source Code:
fruits = ["Apple", "Banana", "Mango"]
print(fruits)
Output:
['Apple', 'Banana', 'Mango']
Result: Thus the program for create and display list was executed successfully.
Experiment 7: Add Element to List
Aim: To add an element to a list.
Source Code:
colors = ["Red", "Blue"]
[Link]("Green")
print(colors)
Output:
['Red', 'Blue', 'Green']
Result: Thus the program for add element to list was executed successfully.
Experiment 8: Largest Number in List
Aim: To find the largest number in a list.
Source Code:
numbers = [12, 45, 7, 89, 23]
largest = max(numbers)
print("Largest number is:", largest)
Output:
Largest number is: 89
Result: Thus the program for largest number in list was executed successfully.
Experiment 9: String Length
Aim: To find the length of a string.
Source Code:
text = "Python"
print(len(text))
Output:
6
Result: Thus the program for string length was executed successfully.
Experiment 10: Reverse a String
Aim: To reverse a string.
Source Code:
text = "Python"
reverse = text[::-1]
print(reverse)
Output:
nohtyP
Result: Thus the program for reverse a string was executed successfully.
Experiment 11: Palindrome String
Aim: To check whether a string is palindrome or not.
Source Code:
text = input("Enter a word: ")
if text == text[::-1]:
print("Palindrome")
else:
print("Not Palindrome")
Output:
Enter a word: madam
Palindrome
Result: Thus the program for palindrome string was executed successfully.
Experiment 12: Function Program
Aim: To create and call a function in Python.
Source Code:
def greet():
print("Welcome to Python")
greet()
Output:
Welcome to Python
Result: Thus the program for function program was executed successfully.