0% found this document useful (0 votes)
5 views2 pages

One Page Python Programs

The document contains six sets of Python programs covering various basic programming concepts. Each set includes two programs, such as calculating sums, checking voting eligibility, and finding areas and perimeters. The programs utilize loops, conditionals, and basic arithmetic operations to demonstrate foundational programming skills.

Uploaded by

lolese3175
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)
5 views2 pages

One Page Python Programs

The document contains six sets of Python programs covering various basic programming concepts. Each set includes two programs, such as calculating sums, checking voting eligibility, and finding areas and perimeters. The programs utilize loops, conditionals, and basic arithmetic operations to demonstrate foundational programming skills.

Uploaded by

lolese3175
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/ 2

Python Programs (SET 1 to SET 6)

SET 1:
1. First 10 natural numbers using for loop
for i in range(1, 11):
print(i)

2. Sum of two numbers


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Sum is:", a + b)

SET 2:
1. Sum of first 10 natural numbers using while loop
i = 1
total = 0
while i <= 10:
total += i
i += 1
print("Sum is:", total)

2. Product of two numbers


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Product is:", a * b)

SET 3:
1. Check voting eligibility
age = int(input("Enter your age: "))
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")

2. Reverse a number
num = int(input("Enter a number: "))
rev = 0
while num > 0:
rev = rev * 10 + num % 10
num //= 10
print("Reversed number:", rev)

SET 4:
1. Check if number is positive, negative or zero
num = int(input("Enter a number: "))
if num > 0:
print("Positive")
elif num < 0:
print("Negative")
else:
print("Zero")

2. Armstrong number check


num = int(input("Enter a number: "))
temp = num
sum = 0
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if sum == num:
print("Armstrong number")
else:
print("Not an Armstrong number")

SET 5:
Python Programs (SET 1 to SET 6)

1. Sum of numbers in a list


numbers = [10, 20, 30, 40, 50]
total = sum(numbers)
print("Sum of list:", total)

2. Area and perimeter of rectangle


length = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))
area = length * breadth
perimeter = 2 * (length + breadth)
print("Area:", area)
print("Perimeter:", perimeter)

SET 6:
1. Simple Interest (1 year)
P = float(input("Enter principal amount: "))
R = float(input("Enter rate of interest: "))
T = 1
SI = (P * R * T) / 100
print("Simple Interest is:", SI)

2. Print odd numbers from 1 to n using while loop


n = int(input("Enter value of n: "))
i = 1
while i <= n:
print(i)
i += 2

You might also like