0% found this document useful (0 votes)
22 views2 pages

12 APractical 2

The document provides a list of practical exercises for Class XII A Computer Science, including two Python programs. The first program calculates the average of three user-input numbers, while the second program analyzes a line of text to count uppercase letters, lowercase letters, alphabets, digits, and spaces. Each program includes sample code and expected output.

Uploaded by

evanshisaini123
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)
22 views2 pages

12 APractical 2

The document provides a list of practical exercises for Class XII A Computer Science, including two Python programs. The first program calculates the average of three user-input numbers, while the second program analyzes a line of text to count uppercase letters, lowercase letters, alphabets, digits, and spaces. Each program includes sample code and expected output.

Uploaded by

evanshisaini123
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/ 2

Class XII A Computer Science

List of Practical –
1. Write a Python program to take three numbers from user and print their
average.

#Program to find average of three numbers


a = int(input("Enter first number : "))
b = int(input("Enter second number : "))
c = int(input("Enter third number : "))
avg = (a+b+c)/3
print("Average of ", a, b, "and", c, "=", avg)

Output-
Enter first number : 10
Enter second number : 20
Enter third number : 30
Average of 10 20 and 30 = 20.0
2. Write a Python program to read a line and print number of uppercase
letters, number of lowercase letters, number of alphabets and number
of digits in it.

# Program to read a line and print number of uppercase letters,


#number of lowercase letters, number of alphabets and number
#of digits
s = input("Enter some text : ")
acount = ucount = lcount = dcount = scount = 0
for i in s:
if i.isalpha():
acount = acount +1
if i.isupper():
ucount = ucount + 1
elif i.islower() :
lcount += 1
elif i.isdigit():
dcount += 1
elif i.isspace():
scount = scount + 1
print("Number of alphabets = ", acount)
print("Number of uppercase letters = ", ucount)
print("Number of lowercase letters = ", lcount)
print("Number of digits = ", dcount)
print("Number of spaces = ", scount)

Output
Enter some text : I Am 15 YearS Old
Number of alphabets = 11
Number of uppercase letters = 5
Number of lowercase letters = 6
Number of digits = 2
Number of spaces = 4

You might also like