Python Programs 2024-2025
Python Programs 2024-2025
a=5
b=6
c=7
# 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)
x=5
y = 10
# create a temporary variable and swap the values
temp = x
x=y
y = temp
print(x,y)
4. Square of a number:
X=20
Print(x*x)
5. Check whether a number is even or odd.
num1=20
if(num1%2==0):
print(“the given number is even”)
else:
print(“The given number is odd”)
6. Check whether Year is a Leap Year or not.
PI =3.142
R=4
Area=PI*r*r
Print(Area)
14.Slicing of List
List Length
To determine how many items a list has, use the len() function:
Range value:
While loop:
Square of a number:
square root: