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

Python Programs Basics

The document contains a series of Python code snippets that perform various calculations and checks, including simple interest, circle properties, number operations, voting eligibility, even/odd checks, leap year determination, vowel/consonant identification, grade assignment based on marks, and income tax calculation. Each section prompts the user for input and displays the results accordingly. The code is structured to handle basic mathematical and logical operations.

Uploaded by

mypcm249
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)
4 views2 pages

Python Programs Basics

The document contains a series of Python code snippets that perform various calculations and checks, including simple interest, circle properties, number operations, voting eligibility, even/odd checks, leap year determination, vowel/consonant identification, grade assignment based on marks, and income tax calculation. Each section prompts the user for input and displays the results accordingly. The code is structured to handle basic mathematical and logical operations.

Uploaded by

mypcm249
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

1.

Calculate Simple Interest


# Simple Interest = (P × R × T) / 100
p = float(input("Enter Principal Amount: "))
r = float(input("Enter Rate of Interest: "))
t = float(input("Enter Time (in years): "))

si = (p * r * t) / 100
print("Simple Interest =", si)

2. Circle - Area, Perimeter, Diameter


import math

r = float(input("Enter Radius of Circle: "))


area = math.pi * r ** 2
perimeter = 2 * math.pi * r
diameter = 2 * r

print(f"Area = {area:.2f}")
print(f"Perimeter = {perimeter:.2f}")
print(f"Diameter = {diameter:.2f}")

3. Square, Cube, Square Root, Cube Root


import math

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


print("Square:", num ** 2)
print("Cube:", num ** 3)
print("Square Root:", math.sqrt(num))
print("Cube Root:", num ** (1/3))

4. Voting Eligibility
age = int(input("Enter Age: "))
nationality = input("Enter Nationality: ").lower()

if age >= 18 and nationality == "indian":


print("Eligible to vote")
else:
print("Not eligible to vote")

5. Even or Odd
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")

6. Leap Year or Not


year = int(input("Enter a year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print("Leap Year")
else:
print("Ordinary Year")

7. Vowel or Consonant
ch = input("Enter a character: ").lower()

if ch in 'aeiou':
print("Vowel")
elif ch.isalpha():
print("Consonant")
else:
print("Not a valid alphabet character")

8. Grade Based on Marks


marks = float(input("Enter your marks (out of 100): "))

if marks >= 90:


print("Grade: A")
elif marks >= 80:
print("Grade: B")
elif marks >= 70:
print("Grade: C")
elif marks >= 60:
print("Grade: D")
else:
print("Grade: F")

9. Income Tax Calculation


income = float(input("Enter your income in lakhs (e.g., 7.5 for 7.5 lakhs): "))

tax = 0
if income > 10:
tax = (income - 10) * 0.30 + (2 * 0.20) + (3 * 0.10)
elif income > 8:
tax = (income - 8) * 0.20 + (3 * 0.10)
elif income > 5:
tax = (income - 5) * 0.10

print(f"Tax Amount: Rs.{tax * 100000:.2f}")

You might also like