0% found this document useful (0 votes)
6 views

Practical File(AI-Python)

The document contains a practical file for Class X (AI) focusing on Python programming. It includes various programming exercises such as checking if a person is a teenager, determining if a number is even or odd, calculating the area of a circle, and generating a multiplication table. Each exercise provides code snippets along with sample input and output for clarity.

Uploaded by

pkm69.bpt
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)
6 views

Practical File(AI-Python)

The document contains a practical file for Class X (AI) focusing on Python programming. It includes various programming exercises such as checking if a person is a teenager, determining if a number is even or odd, calculating the area of a circle, and generating a multiplication table. Each exercise provides code snippets along with sample input and output for clarity.

Uploaded by

pkm69.bpt
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/ 9

PRACTICAL FILE

CLASS-X(AI)
PYTHON
1. Write a program to find out whether someone is teenager or not.
age=int(input(Enter your age:))
if age>=13 and age<=19:
print(“Teen ager”)
else
print(“Not a Teen ager”)

Enter Your Age:14


Teen Ager

2. Write a program to find out whether an


inputted number is even number or not.

a=int(input(“Enter a number”))
if a%2==0:
print(“Even number”)
else: Enter a Number:4
print(“Odd number”) Even Number

3. Write a program to find out the area of a circle


radius=float(input(“Enter radius of a circle”))
area=3.141*radius*radius
print(“Area of a circle is:”, area)

Enter radius of a circle:10


Area of a Circle is:314.1

4. Write a program to print the reverse


number of an inputed number.
b=0
n=int(input(“Enter a number”))
a=n%10
b=b*10+a
n=n//10
print(“Reverse number is”, b)

Enter a number:105
Reverse number is:501
5. Write a program to convert dollar into rupees
dollar=float(input(“Enter Value for Dollar”))
ex_rate=float(input(“Enter Value for Exchange Rate”))
rupees=dollar*ex_rate
print(“After Converting Dollar into Rupees Value is”,rupees)

Enter value for Dollar:10


Enter Value for Exchange
Rate:85.60
After Converting Dollar into
Rupees Value is”, 856
6. Write a program to compute the net run rate
for a tournament.
#Enter details for team, for and against data
tn=input("Enter Team name:")
n=int(input("Enter no. of matches played:"))
#variables to store total scores and overs tr=0
to=0
tagr=0
togr=0
#Entering runs and overs and adding them for n number of matches for i in
range(n):
r=int(input("Enter runs scored in match"+str(i+1)+":")) o=int(input("Enter
overs played:"))
tr=r+tr
to=to+o
agr=int(input("Enter runs conceded in match"+str(i+1)+":")) ogr=int(input("Enter overs
bowled:"))
tagr+=agr Enter Team name:India
togr+=ogr Enter no. of matches played:3
Enter runs scored in match1:254
#Computing the net runrate
Enter overs played:47
nrr=(tr/to)-(tagr/togr) Enter runs conceded in match1:253
#Displaying the net runrate Enter overs bowled:50
Enter runs scored in match2:199
print("Net run rate is:",nrr) Enter overs played:50
Enter runs conceded in match2:110
Enter overs bowled:35
Enter runs scored in match3:225
Enter overs played:50
Enter runs conceded in match3:103
Enter overs bowled:41
Net run rate is:0.9138321995464853
7. Write a program to check whether the given character is an uppercase letter or
lowercase letter or a digit or a special character.
#Input the character to check
ch=input("Enter Any Character:")
'''Checking whether it is upperletter or
lowerletter or digit or a special
character''' if ch.isupper():
print(ch, " is an upper case
letter") elif ch.isupper():
print(ch, " is a lower case letter")
elif ch.isdigit():
print(ch, " is a
digit") elif
ch.isspace():
print(ch, " is a
space") else:
print(ch,"
8. Write is a special
a program to findcharacter")
the maximum number out of the given three numbers.
#Take input or three number to compare
n1=int(input("Enter the Number1:"))
n2=int(input("Enter the Number2:"))
n3=int(input("Enter the Number3:"))
if n1>n2 and n1>n3:
print(n1, " - Number 1 is greater")
elif n1>n2 and n1>n3:
print(n2, " - Number 2 is greater")
elif n3>n1 and n3>n2:
print(n3, " - Number 3 is greater")
else:
print("All are same")
9. An electric power distribution company charges its domestic consumers as follows
Consumption Units Rate of Charge
0-100 Rs. 1 per unit
101-300 Rs. 100 plus Rs. 1.25 per unit in excess of 100
301-500 Rs. 350 plus Rs. 1.50 per unit in excess of 300
500 and above Rs. 650 plus Rs. 1.75 per unit in excess of 500
Write a program that read the customer number & power consumed and prints the amount
to be paid by the customer. Note that output should be well formatted.
#Input Data
cno=int(input("Enter Cusumer Number:"))
pc=int(input("Enter power consumed:")) #Computing bill

amount based on power consumed if pc>0 and pc<=100:


bill_amt=pc*1
elif pc>100 and pc<=300:
bill_amt=100+(pc-100)*1.25
elif pc>300 and pc<500:
bill_amt=350+(pc-300)*1.50 elif
pc>500: bill_amt=650+(pc-
500)*1.75 else:

print("Invalid Power Consumed Units") #Printing


the bill in proper format print("~"*60)

print("\t\tABC Power Company Ltd.") print("~"*60)


print("Consumer Number:",cno)
print("Consumed Units:",pc)
print(" ")
print("Bill Amount:",bill_amt)
10. Write a program to check whether the entered number is Armstrong or not.

#Enter a number to check


n=int(input("Enter number to check:"))
#Store the original number into temporary variable t=n
s=0
#Computing the sum of cube of each digit and iterating until n=0 while
n!=0:
r=n%10
n//=10
#Checking & displaying whether armstrong or not if
t==s:
print(s," is Armstrong number")
else:
print(s," is not an Artmstrong number")

11. Write a program to print a multiplication table of the entered number.

#Take input to accept a nmuber for printing Multiplication table

n=int(input("Enter number to print multiplication table:"))

#Take for loop for multiple for i

in range(1,11):

print(n," x ", i, " = ", n*i )


12. Write a program to generate the following pattern:

2 3

4 5 6

7 8 9 10

11 12 13 14 15

#Take input for n lines

n=int(input("Enter n:"))

#Generating Pattern

k=1

for i in range(1,n+1):

for j in range(1,i+1):

print(k,end=" ")

k=k+1

print()
13. Write a program to create a list of students' marks with user-defined values and
find the maximum.

#Take input for n lines

n=int(input("Enter no. of subjects:"))

#Creating empty list

l=[]

#Accepting marks and appending marks into the list

for i in range(n):

m=int(input("Enter marks:"))

l.append(m)

print("Maximum marks scored:",max(l)

14. Write a program to create a list of numbers and swap the content with the next value
divisible by 5.
For example: list = [4,25,31,7,35,44,55]
Output: [25,4,31,35,7,55,44]
#Take input for no of subjects
n=int(input("Enter no. of subjects:"))
#Creating empty list
l=[]
#Accepting marks and appending marks into the list
for i in range(n):
m=int(input("Enter marks:"))
l.append(m)
#Swaping elements
for i in range(len(l))
: if l[i] % 5 == 0 :
l [ i ], l [i-1] = l [ i - 1 ] , l [i]
print("List after swap:",l)
15. Write a program to count the frequency of every element in a given list.

#Creating empty list

l = []

#Take input for n no. of elements

n=int(input("Enter the no. of elements:"))

#Append the values into the list

for i in range(n):

val=int(input("Enter value "+str(i+1)+":"))

l.append(val)
#Decalring a dictionary object to store the data

f = {}

for i in l:

if (i in f):

f[i] += 1

else:

f[i] = 1

#Displaying the data

for i, j in f.items():

print(i, "->", j)

You might also like