0% found this document useful (0 votes)
104 views6 pages

Pytohn Programs Class 11

The document contains code snippets for several Python programs: 1) A program to calculate the area of a triangle by taking in three side lengths as input and using the semi-perimeter formula. 2) A program to calculate simple interest by taking in principal amount, rate of interest, and number of years. 3) A program to calculate the area and circumference of a circle by taking in the radius as input. 4) A program to swap the values of two variables using a temporary variable. 5) A program to check if a year entered by the user is a leap year or not.

Uploaded by

Dhruv Anand
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)
104 views6 pages

Pytohn Programs Class 11

The document contains code snippets for several Python programs: 1) A program to calculate the area of a triangle by taking in three side lengths as input and using the semi-perimeter formula. 2) A program to calculate simple interest by taking in principal amount, rate of interest, and number of years. 3) A program to calculate the area and circumference of a circle by taking in the radius as input. 4) A program to swap the values of two variables using a temporary variable. 5) A program to check if a year entered by the user is a leap year or not.

Uploaded by

Dhruv Anand
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/ 6

PTYHON PROGRAM TO FIND AREA OF A TRIANGLE

# Python Program to find the area of triangle

# Three sides of the triangle a, b and c are provided by the


user

a = float(input('Enter first side: '))

b = float(input('Enter second side: '))

c = float(input('Enter third side: '))

# calculate the semi-perimeter

s = (a + b + c) / 2

# calculate the area

area = (s*(s-a)*(s-b)*(s-c)) ** 0.5

print('The area of the triangle is', area)

OUTPUT:

Enter first side:5

Enter second side:6

Enter third side:7

The area of the triangle is 14.70


PYTHON PROGRAM TO CALCULATE SIMPLE INTEREST

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

N = float(input("Enter the number of years : "))

R = float(input("Enter the rate of interest : "))

SI = (P * N * R)/100

print('Simple interest:', SI)

OUTPUT:

Enter the principal amount : 50000

Enter the number of years : 5

Enter the rate of interest : 6

Simple interest: 15000


PYTHON PROGRAM TO FIND AREA OF A CIRCLE

# Python Program to find Area Of Circle using Radius

PI = 3.14

radius = float(input(' Please Enter the radius of a circle: '))

area = PI * radius * radius

circumference = 2 * PI * radius

print(" Area Of a Circle =", area)

print(" Circumference Of a Circle =", circumference)

OUTPUT:

Please Enter the radius of a circle: 4

Area Of a Circle = 50.24

Circumference Of a Circle = 25.12


PYTHON PROGRAM TO SWAP TWO VARIABLES

# Python program to swap two variables

num1 = input('Enter First Number: ')

num2 = input('Enter Second Number: ')

print("Value of num1 before swapping: ", num1)

print("Value of num2 before swapping: ", num2)

# swapping two numbers using temporary variable

temp = num1

num1 = num2

num2 = temp

print("Value of num1 after swapping: ", num1)

print("Value of num2 after swapping: ", num2)

OUTPUT:

Enter First Number: 101

Enter Second Number: 99

Value of num1 before swapping: 101

Value of num2 before swapping: 99

Value of num1 after swapping: 99

Value of num2 after swapping: 101


PYTHON PROGRAM TO CEHCK WHETHER YEAR IS LEAP
YEAR OR NOT

# User enters the year

year = int(input("Enter Year: "))

# Leap Year Check

if year % 4 == 0 and year % 100 != 0:

print(year, "is a Leap Year")

elif year % 100 == 0:

print(year, "is not a Leap Year")

elif year % 400 ==0:

print(year, "is a Leap Year")

else:

print(year, "is not a Leap Year")

OUTPUT:

Enter Year: 2000

2000 is not a Leap Year


NAME: GAUTAM SINGH
ROLL NO.: 11
CLASS: XI(B)
SUBJECT: COMPUTER SCIENCE

You might also like