0% found this document useful (0 votes)
16 views3 pages

Python Programs for Class 10 Students

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)
16 views3 pages

Python Programs for Class 10 Students

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

Python Practical File Programs (Class 10)

1. Menu Driven Program (Area, Perimeter, etc.)


Program:
print("1. Area of Circle")
print("2. Area of Rectangle")
print("3. Circumference of Circle")
print("4. Area of Square")
print("5. Perimeter of Rectangle")

choice = int(input("Enter your choice (1-5): "))

if choice == 1:
r = float(input("Enter radius: "))
print("Area of Circle =", 3.14 * r * r)
elif choice == 2:
l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
print("Area of Rectangle =", l * b)
elif choice == 3:
r = float(input("Enter radius: "))
print("Circumference of Circle =", 2 * 3.14 * r)
elif choice == 4:
s = float(input("Enter side: "))
print("Area of Square =", s * s)
elif choice == 5:
l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
print("Perimeter of Rectangle =", 2 * (l + b))
else:
print("Invalid choice!")
Output:
Enter your choice (1-5): 1
Enter radius: 7
Area of Circle = 153.86

2. Largest among Three Numbers


Program:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

if a >= b and a >= c:


print("Largest number is:", a)
elif b >= a and b >= c:
print("Largest number is:", b)
else:
print("Largest number is:", c)
Output:
Enter first number: 5
Enter second number: 9
Enter third number: 3
Largest number is: 9

3. Arithmetic Operations
Program:
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
op = input("Enter operator (+, -, *, /): ")

if op == '+':
print("Result =", a + b)
elif op == '-':
print("Result =", a - b)
elif op == '*':
print("Result =", a * b)
elif op == '/':
print("Result =", a / b)
else:
print("Invalid operator!")
Output:
Enter first number: 8
Enter second number: 4
Enter operator (+, -, *, /): *
Result = 32.0

4. Even or Odd
Program:
num = int(input("Enter a number: "))

if num % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")
Output:
Enter a number: 11
The number is odd.

5. Prime or Not
Program:
num = int(input("Enter a number: "))
if num > 1:
for i in range(2, num):
if num % i == 0:
print("Not a prime number.")
break
else:
print("Prime number.")
else:
print("Not a prime number.")
Output:
Enter a number: 7
Prime number.

You might also like