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

Python Program

Uploaded by

priyag215695
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)
6 views2 pages

Python Program

Uploaded by

priyag215695
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

Python programs for 11th

1. Write a program to find cube of any number using input method.

# calculate the cube of a number


num = int(input("Please enter a number: "))
cube = num*num*num
print("The cube of", num, "is", cube)

2. A trinagle has three sides a, b, c as 17, 23 and 30. Calculate andf display its area using
heron’s formula-
𝑎+𝑏+𝑐
𝑠= ; 𝐴𝑟𝑒𝑎 = √𝑠(𝑠 − 𝑎)(𝑠 − 𝑏)(𝑠 − 𝑐)
2
import math

# Read the lengths of the sides from the user


a = float(input("Enter the length of side a: "))
b = float(input("Enter the length of side b: "))
c = float(input("Enter the length of side c: "))

# Calculate the semi perimeter


s = (a + b + c) / 2

# Calculate the area using Heron's formula


area = math.sqrt(s * (s - a) * (s - b) * (s - c))

# Print the area


print("The area of the triangle is:", area)

3. Write a program to find square of any number using input method.

# calculate the square of a number


num = int((input("Please enter a number: ")))
square = num*num
print("The square of", num, "is", square)
4. Write a Python program to find sum of two numbers by input method.
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
sum = a + b
print(“The sum of ”, a, “and”, b, “is”, sum)

5. A Python program to find factorial of a number.


# Python 3 program to find
# factorial of given number
def factorial(n):
# single line to find factorial
return 1 if (n==1 or n==0) else n * factorial(n - 1)

# Driver Code
num = 5
print("Factorial of",num,"is",factorial(num))

You might also like