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

Class10 Python Programs

The document contains a collection of basic Python programs suitable for Class 10 students. It includes programs for personal information display, mathematical calculations, area and volume computations, and list manipulations. Each program is presented with code snippets and comments explaining their functionality.
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)
2 views3 pages

Class10 Python Programs

The document contains a collection of basic Python programs suitable for Class 10 students. It includes programs for personal information display, mathematical calculations, area and volume computations, and list manipulations. Each program is presented with code snippets and comments explaining their functionality.
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

Class 10 Python Programs

### Basic Programs

# 1. Personal info
print("Name: Shaurya")
print("Father's Name: Mr. XYZ")
print("Class: 10")
print("School Name: ABC Public School")

# 2. Pattern using print


print("*")
print("**")
print("***")
print("****")

# 3. Square of 7
print("Square of 7 is:", 7*7)

# 4. Sum of 15 and 20
print("Sum =", 15+20)

# 5. km to m
km = int(input("Enter distance in km: "))
print("Meters =", km*1000)

# 6. Table of 5 up to 5 terms
for i in range(1,6):
print("5 x", i, "=", 5*i)

# 7. Simple Interest
P = 2000
R = 4.5
T = 10
SI = (P*R*T)/100
print("Simple Interest =", SI)

# 8. Area + Perimeter of rectangle


l = int(input("Length: "))
b = int(input("Breadth: "))
area = l*b
perimeter = 2*(l+b)
print("Area =", area)
print("Perimeter =", perimeter)

# 9. Area of triangle
base = int(input("Base: "))
height = int(input("Height: "))
area = 0.5*base*height
print("Area of triangle =", area)

# 10. Average marks of 3 subjects


m1 = int(input("Marks 1: "))
m2 = int(input("Marks 2: "))
m3 = int(input("Marks 3: "))
avg = (m1+m2+m3)/3
print("Average =", avg)

# 11. Discounted amount


amount = float(input("Enter amount: "))
discount = float(input("Enter discount %: "))
discounted_amount = amount - (amount*discount/100)
print("Discounted Amount =", discounted_amount)

# 12. Surface Area & Volume of Cuboid


l = int(input("Length: "))
b = int(input("Breadth: "))
h = int(input("Height: "))
surface_area = 2*(l*b + b*h + l*h)
volume = l*b*h
print("Surface Area =", surface_area)
print("Volume =", volume)

# 13. Voting eligibility


age = int(input("Enter age: "))
if age >= 18:
print("Eligible to vote")
else:
print("Not eligible to vote")

# 14. Grade of student


marks = int(input("Enter marks: "))
if marks >= 90:
print("Grade A")
elif marks >= 75:
print("Grade B")
elif marks >= 50:
print("Grade C")
else:
print("Grade D")

# 15. Positive, negative or zero


num = int(input("Enter a number: "))
if num > 0:
print("Positive")
elif num < 0:
print("Negative")
else:
print("Zero")

### List Programs

# 1. Science quiz list


children = ["Arjun","Sonakshi","Vikram","Sandhya","Sonal","Isha","Kartik"]
print(children)
[Link]("Vikram")
[Link]("Jay")
[Link](1) # removes item at 2nd position
print(children)

# 2. First 10 even numbers +1


even = [2,4,6,8,10,12,14,16,18,20]
new = []
for i in even:
[Link](i+1)
print(new)

# 3. Extend + sort
List_1 = [10,20,30,40]
List_1.extend([14,15,12])
List_1.sort()
print(List_1)

# 4. Add two lists


a = [1,2,3]
b = [4,5,6]
c = []
for i in range(len(a)):
[Link](a[i]+b[i])
print(c)

# 5. First 10 natural numbers


for i in range(1,11):
print(i)

# 6. First 10 even numbers


for i in range(2,21,2):
print(i)

# 7. Odd numbers 1 to n
n = int(input("Enter n: "))
for i in range(1,n+1):
if i%2 != 0:
print(i)

# 8. Sum of first 10 natural numbers


s = 0
for i in range(1,11):
s += i
print("Sum =", s)

# 9. Sum of all numbers in a list


nums = [5,8,3,2,7]
s = 0
for i in nums:
s += i
print("Sum of list =", s)

# 10. Even numbers 1 to 50


for i in range(1,51):
if i%2 == 0:
print(i)

You might also like