0% found this document useful (0 votes)
205 views40 pages

Programs Class 10th AI Practical

Uploaded by

ARJUN VYAS
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)
205 views40 pages

Programs Class 10th AI Practical

Uploaded by

ARJUN VYAS
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/ 40

Programs

Questions:

1. Write a program to take 3 digit number as input from user and print
unit place,ten’s place and hundred place number.
2. Check whether a number is even or odd. Number should be user
input.
3. Write a program to find the largest number out of the three
numbers input by the user.
4. Write a program to check whether the given character is an
uppercase letter or lowercase letter or digit or a special character.
Q.5 Check whether a number input by the user is a
prime number and display an appropriate message.
Q.6 Check if an input year is leap year or not.
Q.7 Write a program to print a multiplication table of a
entered number.
Enter number: 2
Table of 2 is:
2 X 1=2
2 X 2=4
2 X 3=6
.
.
2 X 10=20
Q.8 Find the factorial of a number provided by the user .Also
check that the number should not be a zero.
• Factorial of zero is 1
• Factorial of 5! = 5*4*3*2*1
• Output: 120
Q.9 Write a program to check whether a number input by user
is Armstrong or not.
An Armstrong number is a special kind of number in math. It's a
number that equals the sum of its digits, each raised to a power.
Ex:153, 370, 371 and 407 are the Armstrong numbers.
Q.10 Find the square and cube of sum of first five
natural numbers.
• 1+2+3+4+5 =15
• 15**2=225
• 15**3=3375
Q.11 Calculate the sum of the elements of a tuple:
sample_tuple(3,2,5,7,11,6)
Q.12 Write a program to generate the following pattern as per number
of lines entered by the user:
*
**
***
****
Q.13 Find the length of sample List=[11,24,35,17] using for loop.

Ans: refer Q.11 for logic of for loop ,do it yourself.


Q.14 Create a list of five elements, where the user enters the value of
each element. Print the list created.
Q. 15 Write a program to create a list of student's marks with user-
defined values and display the highest score, lowest score and total
number of elements in the list.
Q. 16 Write a program to create a list of numbers. If t number is divisible by 5, then
swap the value with the previous value. Display the final list after swapping.
For example: Input list = [4 , 25 , 31 , 7 , 35 , 44 , 55]
Output = [25 , 4 , 31 , 35 , 7 , 55 , 44]
Q.17 Write a python program to create a tuple named “Record” containing the
following values: 101, ‘Meenakshi’, ‘10th’, ‘C’
Now perform the following operation on tuple:
• Write the statement to display ‘Meenakshi’ and ‘C’
• Write the statement to convert tuple into list.
• Write the statement to add the 80000 at last position in a converted tuple.
Q.18 Write a program to create a dictionary named as CAR detail with
the given values:
Name=BMW, Model=X1, Price=3,950,000.
Now perform the following operations on it.
a) Write a statement to add item ‘Location’ as ‘Noida’.
b) Write a statement to change the price value to 4000000.
c) Write a statement to print the value of model.
d) Write a statement to display all the keys and values separately.
e) Remove the name of car.
Basic explanation of data visualization functions for understanding:

• import matplotlib .pyplot as plt : python module for data visualization


• plt.xlabel() and plt.ylabel(): for x-axis and y-axis label
• plt.title(): for giving graph title
• plt.show(): to show the graph
• Plt.legend(): used to identify data in visualizations by its color
• plt.bar(): for bar graph
• plt.plot(): for line chart
• plt.scatter(): for scatter graph
• plt.pie(): for piechart
• plt.hist(): for histogram
Q.19 Write a program to represent the data on the ratings of mobile
games on bar chart.
The sample data is given as: Pubg, FreeFire, MineCraft, GTA-V, call of
duty, FIFA 22.
The rating of each game is: 4.5, 4.8, 4.7, 4.6, 4.1, 4.3.
Q.19 Output looks like:
Q.20 Consider the following data of a clothes store and plot the data on
the line chart:

Customize the chart as you wish.


Q.21 Observe the given data for monthly sales of one of the salesmen for 6
months. Plot them on the line chart.

Apply the following customizations to the chart:


• Give the title for the chart - "Sales Stats"
• Use the "Month" label for X-Axis and "Sales" for Y-Axis.
• Display legends.
• Use dashed lines with the width 5 point.
• Use red color for the line.
• Use dot marker with blue edge color and black fill color.
Q.22 Write a Python program to plot a scatter plot using following data:
# dataset1
x1 = [89, 43, 36, 36, 95, 10, 66, 34, 38, 20]
y1 = [21, 46, 3, 35, 67, 95, 53, 72, 58, 10]
# dataset2
x2 = [26, 29, 48, 64, 6, 5, 36, 66, 72, 40]
y2 = [26, 34, 90, 33, 38, 20, 56, 2, 47, 15]
23) Write a Python program to draw pie chart for the years and profit arrays
given in the following data:
years = [2016, 2017, 2018, 2019, 2020]
profit = [25, 19, 35, 24, 40]
24) Write a Python program to plot a histogram for the following data:
Height = [189, 185, 195, 149, 189, 147, 154, 174, 169, 195, 159, 192, 155,
191, 153, 157, 140, 144, 172, 157, 181, 182, 166, 167, 174]
25) Printing a Star Equilateral Triangle
# Visit this link (https://www.w3schools.com/colors/colors_rgb.asp)
On the basis of this online tool, try and write answers of all the following
questions:
• What is the output colour when you put R=G=B=255?
• What is the output colour when you put R=G=255, B=0?
• What is the output colour when you put R=255, G=0, B=255?
• What is the output colour when you put R=0, G=255, B=255?
• What is the output colour when you put R=G=B=0?
• What is the output colour when you Put R=0, G=0, B=255?
• What is the output colour when you Put R=255, G=0, B=0?
• What is the output colour when you put R=0, G=255, B=0?
• What is the value of your colour?
• Do it your self by changing the value of RGB identify colour and write
answer of he questions Example Q.1 R=G=B=255 ans colour is white:
26) Create your own pixels on piskelapp
(https://www.piskelapp.com/ )
and make a gif image. Steps:
• Open piskelapp on your browser using Do it yourself
(https://www.piskelapp.com/ )
• Click on create sprite button.
• Apply background for the picture.
• Use pen to draw letter A
• Copy the layer and paste it
• Now erase letter A written previously
• Apply the background colour for layer 2
• Change the pen colour and Write L
• Export the image.
• Follow this link to access animated GIF:
https://piskel-imgstore-b.appspot.com/img/1ca2daf3-299f-11ed-b794-
4b46a4acdf45.gif
Final output

You might also like