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

Markdown To PDF

The document provides a collection of simple Python programs that perform various mathematical and logical tasks, including calculating sums, areas, percentages, and checking conditions like even or odd numbers. Each program includes user input prompts and outputs the results accordingly. The tasks range from basic arithmetic operations to more complex calculations like BMI and eligibility checks.

Uploaded by

Swamp gt
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)
27 views3 pages

Markdown To PDF

The document provides a collection of simple Python programs that perform various mathematical and logical tasks, including calculating sums, areas, percentages, and checking conditions like even or odd numbers. Each program includes user input prompts and outputs the results accordingly. The tasks range from basic arithmetic operations to more complex calculations like BMI and eligibility checks.

Uploaded by

Swamp gt
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/ 3

Here are simple Python programs for each of the tasks:

1. Sum of Two Integers

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


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

2. Area of a Circle

radius = float(input("Enter the radius of the circle: "))


area = 3.14159 * radius * radius
print("The area of the circle is:", area)

3. Area of a Triangle

base = float(input("Enter the base of the triangle: "))


height = float(input("Enter the height of the triangle: "))
area = 0.5 * base * height
print("The area of the triangle is:", area)

4. Percentage Marks

marks1 = float(input("Enter marks of subject 1: "))


marks2 = float(input("Enter marks of subject 2: "))
marks3 = float(input("Enter marks of subject 3: "))
total = marks1 + marks2 + marks3
percentage = (total / 300) * 100
print("The percentage is:", percentage)

5. Area of Square and Triangle

side = float(input("Enter the side of the square: "))


area_square = side * side
print("Area of the square is:", area_square)

base = float(input("Enter the base of the triangle: "))


height = float(input("Enter the height of the triangle: "))
area_triangle = 0.5 * base * height
print("Area of the triangle is:", area_triangle)

6. Simple Interest

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


rate = float(input("Enter the rate of interest: "))
time = float(input("Enter the time in years: "))
simple_interest = (principal * rate * time) / 100
print("Simple Interest is:", simple_interest)

7. Quotient and Remainder

a = int(input("Enter the dividend: "))


b = int(input("Enter the divisor: "))
quotient = a // b
remainder = a % b
print("Quotient:", quotient)
print("Remainder:", remainder)

8. Even or Odd

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


if number % 2 == 0:
print("The number is even")
else:
print("The number is odd")

9. Largest Among Three Integers


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
largest = max(a, b, c)
print("The largest number is:", largest)

10. Lowest Among Three Integers

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


b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
lowest = min(a, b, c)
print("The lowest number is:", lowest)

11. Area of Rectangle

length = float(input("Enter the length of the rectangle: "))


breadth = float(input("Enter the breadth of the rectangle: "))
area = length * breadth
print("The area of the rectangle is:", area)

12. Calculate BMI

weight = float(input("Enter your weight in kilograms: "))


height = float(input("Enter your height in meters: "))
bmi = weight / (height * height)
print("Your BMI is:", bmi)

13. Square, Cube, and Square Again

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


print("n² =", n * n)
print("n³ =", n * n * n)
print("n² again =", n * n)

14. Average Marks

marks = []
for i in range(5):
mark = float(input(f"Enter marks of subject {i + 1}: "))
marks.append(mark)
average = sum(marks) / len(marks)
print("The average marks are:", average)

15. Height Conversion (cm to feet and inches)

height_cm = float(input("Enter height in cm: "))


height_inch = height_cm / 2.54
height_feet = int(height_inch // 12)
height_inch %= 12
print(f"Height: {height_feet} feet and {height_inch:.2f} inches")

16. Eligibility to Vote

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


if age >= 18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

17. Divisibility Check

num1 = int(input("Enter the first number: "))


num2 = int(input("Enter the second number: "))
if num1 % num2 == 0:
print("The first number is fully divisible by the second number")
else:
print("The first number is not fully divisible by the second number")

18. Area and Perimeter of Parallelogram


base = float(input("Enter the base of the parallelogram: "))
width = float(input("Enter the width of the parallelogram: "))
height = float(input("Enter the height of the parallelogram: "))
area = base * height
perimeter = 2 * (base + width)
print("The area of the parallelogram is:", area)
print("The perimeter of the parallelogram is:", perimeter)

You might also like