Some Basic Phython Codes
Some Basic Phython Codes
CLASS: IX
SUBJECT: ARTIFICIAL INTELLIGENCE
PRACTICAL FILE WORK
SESSION: 2025-2026
INSTRUCTIONS:
1. The cover should contain your Name, Class, Section, Roll Number, Subject (Artificial
Intelligence Practical File) and Session (2025-2026)
2. First page of the practical file should contain your name, class, section and roll
number.
3. Second page of the practical file should contain the index. (keep 2 pages for index)
a. The index will consist of Sl.No., Questions, Page No. and Signature.
4. The codes and outputs will start from the fourth page.
5. The question and the code have to be written on the right-hand side ruled page of
the practical file.
6. Execute the codes in your system, take a screenshot of the output. Take a printout
of the screenshots and paste them on the immediate left-hand side white page.
7. Each page should contain ONE question, code and output only (no matter how
small the code is).
8. Minimal decorations only.
9. Do not use red, pink, orange or purple colours.
10. Covering the practical file is not compulsory, but if you want you can use white
chart paper only.
Q.1. Write a program in python to take the name of your favourite sport, favourite team and favourite
player as input and print them accordingly.
CODE:
FSport=input("Enter your favourite sport")
FTeam=input("Enter your favourite team")
FPlayer=input("Enter your favourite player")
print("Your favourite sport is: ",FSport)
print("Your favourite team is: ",FTeam)
print("Your favourite player is: ",FPlayer)
Q.2. Write a program in python to take the side of a cube as input, calculate and print its surface area
and volume.
CODE:
Side=int(input("Enter the side of a cube"))
S_area=6*(Side**2)
volume= Side**3
print("The surface area of the Cube is: ",S_area)
print("The volume of the cube is: ",volume)
Q.3. Write a program in python to take the temperature in Celsius as input, convert it into Fahrenheit and
print it.
CODE:
C=int(input("Enter temperature in celsius"))
F=(C*1.8)+32
print("The temperature in fahrenheit is: ",F)
Q.4. Write a program in python to take three sides of a triangle as input and check if they form a triangle
or not.
CODE:
a=int(input("Enter first side of a triangle"))
b=int(input("Enter second side of a triangle"))
c=int(input("Enter third side of a triangle"))
if a+b>c and b+c>a and c+a>b:
print("The sides form a triangle")
else:
print("The sides do not form a triangle")
Q.5.Write a program in python to take a number as input and check if it is divisible by 4 or 5 or both.
CODE:
num=int(input("Enter a number"))
if num%4==0 and num%5!=0:
print(num," is divisible by 4 only")
elif num%5==0 and num%4!=0:
print(num," is divisible by 5 only")
elif num%4==0 and num%5==0:
print(num," is divisible by both 4 and 5")
else:
print(num," is not divisible by either 4 or 5")
Q.6. Write a program in python to take a number as input and check if it is positive even or odd, or
negative even or odd. [Consider 0 as a positive even number]
CODE:
num=int(input("Enter a number"))
if num>=0:
if num%2==0:
print("The number is positive even")
else:
print("The number is positive odd")
else:
if num%2==0:
print("The number is negative even")
else:
print("The number is negative odd")