[go: up one dir, main page]

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

STD X AI PYTHON PROGRAMS 2024-24 New

Uploaded by

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

STD X AI PYTHON PROGRAMS 2024-24 New

Uploaded by

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

1.

#Program to input 2 numbers and perform simple arithmetic operations


n1=int(input("Enter Number 1:"))
n2=int(input("Enter Number 2:"))
print("Number 1 :",n1,"Number 2:",n2)
print("Sum is ",n1+n2)
print("Product is ",n1*n2)
print("Quotient is ",n1/n2)
print("Remainder is ",n1%n2)

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)

3. #Program to find how many days is a million seconds


sec=1e6
minutes=sec/60
hours=minutes/60
days=hours/24
print("Days:",days," or Hours :",hours,"or minutes",minutes)

4. #Program to input 2 numbers and interchange their values


n1=int(input("Enter Number 1:"))
n2=int(input("Enter Number 2:"))
print("Before interchanging Number 1 :",n1,"Number 2:",n2)
n1,n2=n2,n1
print("After interchanging Number 1 :",n1,"Number 2:",n2)

5. #Program to input a number and check it is even or odd


num=int(input("Enter Number :"))
if num%2==0:
print(num, "is even number")
else:
print(num, "is odd number")

6. #Program to input 3 numbers and find the greater number


n1=int(input("Enter Number 1:"))
n2=int(input("Enter Number 2:"))
n3=int(input("Enter Number 3:"))
max=n1
if n2>max:
max=n2
if n3>max:
max=n3
print("Greater number is :",max)

7. #Program to print square of first 10 natural numbers


print("square of first 10 natural numbers are :")
for i in range(1,11):
print(i, i*i)
8. #PROGRAM TO CALCULATE TOTAL MARKS FROM MARKS OF DIFF SUB IN A LIST
Marks=[80,98,78,87,92]
tot=0
print("Marks obtained in 5 subjects are :",Marks)
for sm in Marks:
tot=tot+sm
print("Total Marks are :",tot)

9. #PROGRAM TO print the numbers divisible by 5 from a given list of numbers


N=[10,15,21,34,90,99,100]
print("list of numbers :",N)
print("numbers divisible by 5 are :")
for num in N:
if num%5==0:
print(num)

10. #Write a program to add the elements of the two


lists L1=[1,2,3,4,5]
L2=[10,20,30,40,50]
L3=[]
for i in range(0,len(L1)): L3.append(L1[i]
+L2[i])
print("List 1 :",L1)
print("List 2 :",L2)
print("List 3 :",L3)

11. #find the average speed of a vehicel using numpy


import numpy
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = numpy.mean(speed)
print("Average speed of vehicle is ",x)

12. # median() method to find the middle value using numpy

import numpy
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = numpy.median(speed)
print(x)

13. #display the contents of csv file


import csv
with open("data1.csv","r",newline='\n') as fh:
sreader=csv.reader(fh)
for row in sreader:
print(row)
14. Plot a bar graph
import matplotlib.pyplot as plt

courses=['c','c++','java','python']
values=[10,30,40,100]
fig = plt.figure(figsize = (10, 5))

# creating the bar plot


plt.bar(courses, values, color ='maroon',width = 0.4)

plt.xlabel("Courses offered")
plt.ylabel("No. of students enrolled")
plt.title("Students enrolled in different courses")
plt.show()

15. Plot a pie chart


# Import libraries
import matplotlib.pyplot as plt

# Creating dataset
cars = ['AUDI', 'BMW', 'FORD','TESLA', 'JAGUAR', 'MERCEDES']

data = [23, 17, 35, 29, 12, 41]


# Creating plot
fig = plt.figure(figsize =(10, 7))
plt.pie(data, labels = cars)
# show plot
plt.show()

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

Perform the following tasks on the list in sequence-

○ 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.

• Create a list num=[23,12,5,9,65,44]


○ Print the length of the list
○ Print the elements from second to fourth position using positive indexing
○ Print the elements from position third to fifth using negative indexing

● Write a program to display line chart from (2,5) to (9,10).

● Write a program to display a scatter chart for the following points

(2,5), (9,10),(8,3),(5,7),(6,18).

● Read csv file saved in your system and display 10 rows.

● 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

You might also like