0% found this document useful (0 votes)
13 views6 pages

Program 1

The document contains a series of Python programs that perform various tasks such as printing personal information, calculating squares and sums, converting kilometers to meters, and determining voting eligibility. Each program is designed to demonstrate basic programming concepts like input/output, loops, conditionals, and list operations. Overall, it serves as a practical guide for beginners to learn fundamental programming skills.

Uploaded by

anshiaggarwal6
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Program 1

The document contains a series of Python programs that perform various tasks such as printing personal information, calculating squares and sums, converting kilometers to meters, and determining voting eligibility. Each program is designed to demonstrate basic programming concepts like input/output, loops, conditionals, and list operations. Overall, it serves as a practical guide for beginners to learn fundamental programming skills.

Uploaded by

anshiaggarwal6
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PROGRAM 1: Print personal information

print("Name: Anshi Aggarwal")

print("Father's Name: Pronesh Aggarwal")

print("Class: 9")

print("School Name: Elpro International School")

PROGRAM 2: Print pattern

print("*")

print("**")

print("***")

print("****")

PROGRAM 3: Square of a number

num = int(input("Enter a number: "))

print("Square:", num * num)

PROGRAM 4: Sum of two numbers

a = int(input("Enter first number: "))

b = int(input("Enter second number: "))

print("Sum:", a + b)

PROGRAM 5: Kilometers to meters

km = float(input("Enter distance in km: "))

print("Distance in meters:", km * 1000)

PROGRAM 6: Table of a number

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


for i in range(1, 11):

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

PROGRAM 7: Simple Interest

p = float(input("Enter principal: "))

r = float(input("Enter rate: "))

t = float(input("Enter time: "))

si = (p * r * t) / 100

print("Simple Interest:", si)

PROGRAM 8: Area & perimeter of rectangle

l = float(input("Enter length: "))

b = float(input("Enter breadth: "))

print("Area:", l * b)

print("Perimeter:", 2 * (l + b))

PROGRAM 9: Area of triangle

base = float(input("Enter base: "))

height = float(input("Enter height: "))

print("Area of triangle:", 0.5 * base * height)

PROGRAM 10: Average marks

m1 = int(input("Enter marks 1: "))

m2 = int(input("Enter marks 2: "))

m3 = int(input("Enter marks 3: "))

avg = (m1 + m2 + m3) / 3

print("Average marks:", avg)


PROGRAM 11: Discounted amount

amount = float(input("Enter amount: "))

discount = float(input("Enter discount percentage: "))

final_amount = amount - (amount * discount / 100)

print("Amount after discount:", final_amount)

PROGRAM 12: Surface area & volume of cuboid

l = float(input("Enter length: "))

b = float(input("Enter breadth: "))

h = float(input("Enter height: "))

print("Surface Area:", 2 * (l*b + b*h + l*h))

print("Volume:", l * b * h)

PROGRAM 13: List operations

children = ["Arjun", "Sonakshi", "Vikram", "Sandhya", "Sonal", "Isha", "Kartik"]

print(children)

[Link]("Vikram")

[Link]("Jay")

[Link](1)

print(children)

PROGRAM 14: List indexing

num = [23, 12, 5, 9, 65, 44]

print("Length:", len(num))

print(num[1:4])

print(num[-4:-1])
PROGRAM 15: First 10 even numbers + add 1

lst = []

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

[Link](i + 1)

print(lst)

PROGRAM 16: Extend & sort list

List_1 = [10, 20, 30, 40]

List_1.extend([14, 15, 12])

List_1.sort()

print(List_1)

PROGRAM 17: Voting eligibility

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

if age >= 18:

print("Eligible to vote")

else:

print("Not eligible to vote")

PROGRAM 18: 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("Fail")

PROGRAM 19: Positive / Negative / Zero

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

if n > 0:

print("Positive")

elif n < 0:

print("Negative")

else:

print("Zero")

PROGRAM 20: First 10 natural numbers

for i in range(1, 11):

print(i)

PROGRAM 21: First 10 even numbers

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

print(i)

PROGRAM 22: Odd numbers from 1 to n

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

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

print(i)

PROGRAM 23: Sum of first 10 natural numbers


total = 0

for i in range(1, 11):

total += i

print("Sum:", total)

PROGRAM 24: Sum of numbers in a list

lst = [10, 20, 30, 40]

print("Sum of list:", sum(lst))

You might also like