Class_X_Practical_File_Work
Class_X_Practical_File_Work
Practical File
2024-25
Made By:
Tanmay Sinha
10-C
1
INDEX
9 Python program to check whether the given integer is a prime number or not
2
INDEX
S.No. Program Title Teacher’s Signature
16 Printing the string elements of a List
17 Program to accessing elements of a
list using loops
18 Different Functions of Numpy
19 Program to create NumPy Array
20 Program to make bar chart using
pandas and matplotlib libraries
3
Python program to check whether the given number is even or not.
Output:
Enter a number: 7
The number is Odd.
Enter a number: 6
The number is Even.
Python program to convert the temperature in degree centigrade to
Fahrenheit
Output:
Output:
Input the radius of the circle: 7
The circumference of the circle is: 43.96
The area of the circle is: 153.86
Python program to check whether the given integer is a multiple of
both 5 and 7
Output:
Enter an integer: 33
33 is not a multiple of both 5 and 7
Python program to display the given integer in a reverse manner
Output:
Enter a positive integer: 739
937
Python program to display all the multiples of 3 within the range 10 to
50
for i in range(10,50):
if (i%3==0):
print(i)
12
Output: 15
18
21
24
27
30
33
36
39
42
45
48
Python program to check whether the given integer is a prime number
or not
numbers = [4,2,7,1,8,3,6]
f = 0 #flag
x = int(input("Enter the number to be found out: "))
for i in range(len(numbers)):
if (x==numbers[i]):
print("Successful search, the element is found at position", i)
f=1
break
if(f==0):
print("Oops! Search unsuccessful")
Output:
Enter the number to be found out: 7
Successful search, the element is found at position 2
Python Program to Find the Factorial of a Number
num = 7
factorial = 1
# check if the number is negative, positive or zero
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
Output:
The factorial of 7 is 5040
Python Program to Check Armstrong Number
num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
• # printing list1
• print("List element are: ", list1)
16
Printing the string elements of a List
• # declaring list with string elements
• list2 = ["New Delhi", "Mumbai", "Chennai", "calcutta"]
• # printing list2
• print("List elements are: ", list2)
17
Program to accessing elements of a list using loops
a= [32,55,7,12,65,32,90,27,12]
for i in a:
print(i)
Output
32
55
7
12
65
32
90
27
12
18
Different Functions of Numpy
import numpy as np
# Creating array object
arr = np.array( [[ 1, 2, 3],
[ 4, 2, 5]] )
Output:
# Printing type of arr object
print("Array is of type: ", type(arr)) Array is of type: <class 'numpy.ndarray'>
# Printing array dimensions (axes) No. of dimensions: 2
print("No. of dimensions: ", arr.ndim) Shape of array: (2, 3)
# Printing shape of array Size of array: 6
print("Shape of array: ", arr.shape)
Array stores elements of type: int64
# Printing size (total number of elements) of array
print("Size of array: ", arr.size)
# Printing type of elements in array
print("Array stores elements of type: ", arr.dtype) 19
Program to create NumPy Array
import numpy as np
Output:
# Creating array from list with type float
a = np.array([[1, 2, 4], [5, 8, 7]], dtype = 'float') Array created using passed list:
print ("Array created using passed list:\n", a) [[1. 2. 4.]
[5. 8. 7.]]
# Creating array from tuple
b = np.array((1 , 3, 2)) Array created using passed tuple:
print ("\nArray created using passed tuple:\n", b) [1 3 2]
20
Program to make bar chart using pandas and matplotlib libraries
import pandas as pd
import matplotlib.pyplot as plot
# A python dictionary
data = {"City":["London", "Paris", "Rome"],
"Visits":[20.42,17.95,9.7] };
# Dictionary loaded into a DataFrame
dataFrame = pd.DataFrame(data=data);
# Draw a vertical bar chart
dataFrame.plot.bar(x="City", y="Visits", rot=70,
title="Number of tourist visits - Year 2018");
plot.show(block=True);
21