STD X AI PYTHON PROGRAMS 2024-24 New
STD X AI PYTHON PROGRAMS 2024-24 New
2. #Program to input 2 length and breadth of rectangle and find its area and perimeter
L=int(input("Enter Length of Rectangle:"))
B=int(input("Enter Breadth of Rectangle:"))
print("Area is ",L*B)
P=2*(L+B)
print("Perimeter is ",P)
import numpy
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = numpy.median(speed)
print(x)
courses=['c','c++','java','python']
values=[10,30,40,100]
fig = plt.figure(figsize = (10, 5))
plt.xlabel("Courses offered")
plt.ylabel("No. of students enrolled")
plt.title("Students enrolled in different courses")
plt.show()
# Creating dataset
cars = ['AUDI', 'BMW', 'FORD','TESLA', 'JAGUAR', 'MERCEDES']
EXTRA QUESTIONS
Write a program to add the elements of the two lists.
Create a list in Python of children selected for science quiz with following names- Arjun, Sonakshi,
Vikram, Sandhya, Sonal, Isha, Kartik
○ Print the whole list ○ Delete the name “Vikram” from the list
○ Add the name “Jay” at the end ○ Remove the item which is at the second position.
(2,5), (9,10),(8,3),(5,7),(6,18).
● Write a program to read an image and identify its shape using Python
pip install opencv-python
pip install numpy
pip install matplotlib
The steps to read and display an image in OpenCV are:
1. Read an image using imread() function.
2. Create a GUI window and display image using imshow() function.
3. Use function waitkey(0) to hold the image window on the screen by the specified
number of seconds, o means till the user closes it, it will hold GUI window on the
screen.
4. Delete image window from the memory after displaying using
destroyAllWindows() function.
Let’s start reading an image. using cv2.
To read the images cv2.imread() method is used. This method loads an image from
the specified file. If the image cannot be read (because of missing file, improper
permissions, unsupported or invalid format) then this method returns an empty
matrix.
Note:
1. The image should be in the working directory or a full path of image
should be given.
2. By default, OpenCV stores colored images in RGB(Blue Green and Red)
format