0% found this document useful (0 votes)
19 views

Python Programs Samples2

Uploaded by

Sourav Roy
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)
19 views

Python Programs Samples2

Uploaded by

Sourav Roy
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.

Python program to find simple interest

p = float(input("Enter the principle amount : "))


r = float(input("Enter the rate of interest : "))
t = float(input("Enter the time in the years: "))
si = (p*r*t)/100
print("Principle amount: ", p)
print("Interest rate : ", r)
print("Time in years : ", t)
print("Simple Interest : ", si)
2. Python program to return maximum of two numbers

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


num2 = int(input("Enter the second number: "))
if(num1 > num2):
print(num1, "is greater")
elif(num1 < num2):
print(num2, "is greater")
else:
print("Both are equal")
3. Python program to find the area and perimeter of a circle in python
pi=3.14
r = float(input("Enter radius of the circle: "))
area = (pi*r*r)
perimeter = (2*pi*r)
print("The area of circle is ", "%.2f" %area)
print("The perimeter of circle is", "%.2f" %perimeter)

4. Python program to check leap year by using the calendar module


import calendar
year=int(input('Enter the value of year: '))
leap_year=calendar.isleap(year)
if leap_year: # to check condition
print('The given year is a leap year.')
else:
print('The given year is a non-leap year.')
5. Program for largest of three numbers in Python
a = int(input("Enter A: "))
b = int(input("Enter B: "))
c = int(input("Enter C: "))
if a > b:
if a > c:
g=a
else:
g=c
else:
if b > c:
g=b
else:
g=c
print("Greater = ", g)

6. Percentage Discount Calculator Implementation , The discount rates are:


Amount Discount
0-5000 5%
5000-15000 12%
15000-25000 20%
above 25000 30%

amt = int(input("Enter Sale Amount: "))


if(amt>0):
if amt<=5000:
disc = amt*0.05
else:
if amt<=15000:
disc=amt*0.12
else:
if amt<=25000:
disc=0.2 * amt
else:
disc=0.3 * amt
print("Discount : ",disc)
print("Net Pay : ",amt-disc)
else:
print("Invalid Amount")

You might also like