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

Python Programmes

Uploaded by

vikas2reddy10
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Python Programmes

Uploaded by

vikas2reddy10
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

PYTHON PROGRAMMES

1 TO ADD 3 NUMBERS
A= 10
B=15
C=20
D= A+B+C
print(D)

out put will be 45

2. To calculate the average marks in 3 subjects


e = int(input(“Enter marks in English: “)

m=int(input(“Enter marks in Maths: “)

s=int(input(“Enter marks in Science: “)

avg= (e+m+s)/3

print(avg)

print(“average marks is : ”, avg)

3. program to calculate the area and perimeter of a rectangle


length = float(input(“Enter the length : “))

breadth = float(input(“Enter the breadth: “))

area = length * breadth

perimeter = 2 * length + 2 * breadth

print (“Area of the rectangle is : “, area, “sq cm”)

print (“Perimeter of the rectangle is : “,perimeter, “cm”)

4. program to display one of the two alternate messages (eligible to vote or not)

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

If age>= 18 :

print(“You are eligible to vote”)

else:

print(“ Sorry you cannot vote”)


5. Program to find if a given number is even or odd
number = int(input(“Enter a positive integer: “))

if (number%2==0):

print(“The number “, number, “is EVEN”)

else:

print(“The number “, number, “is ODD”)

6. Program to calculate area of Circle


pi=3.14

r=float(input("enter radius: " ))

area = pi*r*r

print(area)

7 PROGRAM TO ASSIGN GRADE

m=int(input(“enter marks”))

if m>=90:

print(“ Grade is A”)

elif (m>=80 and m<=90):

print(“ Grade is B”)

elif(m>=70 and m<=80):

print(“Grade is C”)

else:

print(“Grade is D”)

8 Python program to calculate discount based on the sale amount

Amount Discount

0-5000 5%

5000-15000 12%

15000-25000 20%
above 25000 30%

# input sale amount

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

# checking conditions and calculating discount

if(amt>0):

if amt<=5000:

disc = amt*0.05

elif amt<=15000:

disc=amt*0.12

elif 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy