Class X Practical Program
Class X Practical Program
Program 1
Program:
num=int(input("enter the number"))
sum=0
i=1
while(i<=num):
sum=sum+i
i=i+1
print("the sum is ", sum)
avg=sum/num
print("the avergae is ",avg)
Output
enter the number: 10
The sum is : 55
The average is 5.5
Program 2
Aim: Write a program to check whether the given character is an uppercase letter or
lowercase letter .
Program:
ch = input("Please Enter Your Own Character : ")
if(ch.isupper()):
print(ch, "is an Uppercase Alphabet")
elif(ch.islower()):
print( ch, "is a Lowercase Alphabet")
else:
print( ch, "is Not a Lower or Uppercase Alphabet")
Output:
Please Enter Your Own Character: A
A is an Uppercase Alphabet
Program 3:
Aim:
Write a program to generate a pattern.
1
12
123
1234
12345
Program:
rows = int(input(“enter the rows:”))
for i in range(1, rows+1):
for j in range(1, i+1):
print(j, end=' ')
print("")
Program 4
Aim:
Write a program to find the maximum number out of the given three numbers.
Program:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
num3 = int(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print("The largest number is", largest)
Result:
Thus the program is executed and the output verified.
Output:
Enter first number: 10
Enter second number: 20
Enter third number: 30
The largest number is 30
Program 5:
Aim:
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 for each game is as: 4.5,4.8,4.7,4.6,4.1,4.3.
Program :
import matplotlib.pyplot as plt
rating=[4.5,4.8,4.7,4.6,4.1,4.3]
plt.xlabel('Games')
plt.ylabel('Rating')
plt.show()
Output: