[go: up one dir, main page]

0% found this document useful (0 votes)
6 views4 pages

Class X Python Programs

The document contains a series of Python practical programs for Class X, covering topics such as calculating simple interest, area and perimeter of rectangles, list operations, conditional statements, and array manipulations using NumPy. Each program includes code snippets and print statements to demonstrate functionality. The document serves as a practical guide for students to learn and practice Python programming concepts.

Uploaded by

aakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Class X Python Programs

The document contains a series of Python practical programs for Class X, covering topics such as calculating simple interest, area and perimeter of rectangles, list operations, conditional statements, and array manipulations using NumPy. Each program includes code snippets and print statements to demonstrate functionality. The document serves as a practical guide for students to learn and practice Python programming concepts.

Uploaded by

aakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Class X

Python Practical Programs

1. # Code to calculate the Simple Interest


principle_amount = 2000
roi = 4.5
time = 10
simple_interest = (principle_amount * roi * time)/100
print("datatype of principle amount : ", type(principle_amount))
print("datatype of rate of interest : ", type(roi))
print("value of simple interest : ", simple_interest)
print("datatype of simple interest : ", type(simple_interest))

2. # To calculate Area and


# Perimeter of a rectangle
L=int(input("Length"))
B=int(input("Breadth"))
Area=L*B
Perimeter=2*(L+B)
print("Area:",Area)
print("Perimeter:",Perimeter)

3. List = []
print("Initial blank List: ")
print(List)
# Addition of Elements
# in the List
List.append(1)
List.append(2)
List.append(4)
print("\nList after Addition :")
print(List)

4. # Creating a List
List = [1,2,3,4]
print("Initial List: ")
print(List)
# Addition of Element at specific Position
# (using Insert Method)
List.insert(3, 12)
List.insert(0, 'Kabir')
print("\nList after Insert Operation: ")
print(List)
5. #Addition of multiple elements to the list
List = [1,2,3,4]
print("Initial List: ")
print(List)

# Addition of multiple elements to the List at the end (using Extend Method)
List.extend([8, 'Artificial', 'Intelligence'])
print("\nList after Extend Operation: ")
print(List)

6. # Removing elements from a List


List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12]
print("Intial List: ")
print(List)
# Removing elements from List
# using Remove() method
List.remove(5)
List.remove(6)
print("\nList after Removal:")
print(List)

7. # Removing element from the


# Set using the pop() method
List.pop()
print("\nList after popping an element: ")
print(List)

# Removing element at a
# specific location from the
# Set using the pop() method
List.pop(2)
print("\nContent after pop ")
print(List)

8. # Using Slicing from a List


List= ['G','O','O','D','M','O', 'R','N','I','N','G']
print("Initial List: ")
print(List)
# using Slice operation
Sliced_List = List[3:8]
print("\nSlicing elements in a range 3-8: ")
print(Sliced_List)

9. # Print elements from a


# pre-defined point to end
Sliced_List = List[5:]
print("Elements sliced from 5th element till the end: ")
print(Sliced_List)
10. #Check if the number is positive, we print an appropriate message
num = 3
if num > 0:
print(num, “is a positive number.”)
print(“this is always printed”)
num = -1
if num > 0:
print(num, “is a positive number.”)
print(“this is always printed”)

11. #A program to check if a person can vote


age = input(“Enter Your Age”)
if age >= 18:
print(“You are eligible to vote”)
else:
print(“You are not eligible to vote”)

12. #To check the grade of a student


Marks = 60
if marks > 75:
print("You get an A grade")
elif marks > 60:
print("You get a B grade")
else:
print("You get a C grade")

13. # In this program, we input a number check if the number is positive or negative or zero and
display an appropriate message.

num = float(input("Enter a number: "))


if num >= 0:
if num == 0:
print("Zero")
else:
print("Positive number")
else:
print("Negative number")

14. Creating 1-D Array:


import numpy as np
array1=np.array([10,20,30,40,50])
print(array1)

15. Creating 2-D array


import numpy as np
array1=np.array([[10,20,30,40,50],[100,200,300,400,500]])
print(array1)

16. Creating an array of evenly spaced values


import numpy as np
array1=np.arange(0,10,2)
print(array1)
17. Creating an array of ones
import numpy as np
array1=np.arange(8)
print(array1)

18. Creating an array of zeros


import numpy as np
array1=np.zeros(2,3)
print(array1)

19. Creating an array with random values


import numpy as np
random_array=np.random.random((2,2))
print(random_array)

20. Creating an empty array


import numpy as np
empty_array=np.array(3,2)
print(empty_array)

21. Creating a full array


import numpy as np
full_array=np.full ((2,3),5)
print(array1)

**********************

You might also like