Python

Program to Find Sum of Arithmetic Progression Series

Python Program to Find Sum of Arithmetic Progression Series

In the previous article, we have discussed Python Program to Find Volume and Surface Area of a Cuboid
Arithmetic progression:

An Arithmetic progression is a mathematical sequence of numbers in which the difference between the consecutive terms is constant.

In general, an arithmetic sequence looks like this:  a, a+d, a+2d, a+3d,…………….

where a = first term

d= common difference

n= number of terms in series

Formula : d= second term – first term

The sum of Arithmetic progression Series : Sn = n/2(2a + (n – 1) d)
The Tn (nth term) of Arithmetic progression Series : Tn = a + (n – 1) d

Given a, n, d values and the task is to find the sum of the Arithmetic progression Series.

Examples:

Example 1:

Input:

Given first term = 3
Given total terms = 9
Given common difference = 4

Output:

Given Arithmetic Progression Series Sum with [a,n,d]:( 3 9 4 ) = 171.0
The Given Arithmetic Progression Series nth Term with [a,n,d]:( 3 9 4 ) = 35

Example 2:

Input:

Given first term = 7
Given total terms = 15
Given common difference = 2

Output:

Given Arithmetic Progression Series Sum with [a,n,d]:( 7 15 2 ) =  315.0
The Given Arithmetic Progression Series nth Term with [a,n,d]:( 7 15 2 ) =  35

Program to Find Sum of Arithmetic Progression Series

Below are the ways to find the sum of the Arithmetic progression Series:

Method #1: Using Mathematical Formula (Static Input)

Approach: 

  • Give the first term of arithmetic progression series as static input and store it in a variable.
  • Give the total number of terms of the A.P. series as static input and store it in another variable.
  • Give the common difference of the A.P. series as static input and store it in another variable.
  • Calculate the sum of the given arithmetic progression series using the above given mathematical formula(n/2(2a + (n – 1) d)) and store it in a variable.
  • Calculate the nth term of the given arithmetic progression series using the above given mathematical formula ( Tn = a + (n – 1) d) and store it in another variable.
  • Print the sum and nth term of the given Arithmetic Progression series.
  • The Exit of the program.

Below is the implementation:

# Give the first term of arithmetic progression series as static input
# and store it in a variable.
fst_trm = 2
# Give the total number of terms of the A.P. series as static input and
# store it in another variable.
total_terms = 6
# Give the common difference of the A.P. series as static input and store it
# in another variable.
common_diff = 4
# Calculate the sum of the given arithmetic progression series using the above given
# mathematical formula(n/2(2a + (n – 1) d)) and store it in a variable.
sum_ap = (total_terms * (2 * fst_trm + (total_terms - 1) * common_diff)) / 2
# Calculate the nth term of the given arithmetic progression series using the above
# given mathematical formula ( Tn = a + (n – 1) d) and store it in another variable.
nth_trm_ap = fst_trm + (total_terms - 1) * common_diff
# Print the sum and nth term of the given Arithmetic Progression series.
print("Given Arithmetic Progression Series Sum with [a,n,d]:(",
      fst_trm, total_terms, common_diff, ") = ", sum_ap)
print("The Given Arithmetic Progression Series nth Term with [a,n,d]:(",
      fst_trm, total_terms, common_diff, ") = ", nth_trm_ap)

Output:

Given Arithmetic Progression Series Sum with [a,n,d]:( 2 6 4 ) =  72.0
The Given Arithmetic Progression Series nth Term with [a,n,d]:( 2 6 4 ) =  22

Method #2: Using Mathematical Formula (User Input)

Approach: 

  • Give the first term of arithmetic progression series as user input using the int(input()) function and store it in a variable.
  • Give the total number of terms of the A.P. series as user input using the int(input()) function and store it in another variable.
  • Give the common difference of the A.P. series as user input using the int(input()) function and store it in another variable.
  • Calculate the sum of the given arithmetic progression series using the above given mathematical formula(n/2(2a + (n – 1) d)) and store it in a variable.
  • Calculate the nth term of the given arithmetic progression series using the above given mathematical formula ( Tn = a + (n – 1) d) and store it in another variable.
  • Print the sum and nth term of the given Arithmetic Progression series.
  • The Exit of the program.

Below is the implementation:

# Give the first term of arithmetic progression series as user input using the
# int(input()) function and store it in a variable.
fst_trm = int(input("Enter some random number = "))
# Give the total number of terms of the A.P. series as user input using the int(input()) function and store
# it in another variable.
total_terms = int(input("Enter some random number = "))
# Give the common difference of the A.P. series as user input using the int(input()) function and
# store it in another variable.
common_diff = int(input("Enter some random number = "))
# Calculate the sum of the given arithmetic progression series using the above given
# mathematical formula(n/2(2a + (n – 1) d)) and store it in a variable.
sum_ap = (total_terms * (2 * fst_trm + (total_terms - 1) * common_diff)) / 2
# Calculate the nth term of the given arithmetic progression series using the above
# given mathematical formula ( Tn = a + (n – 1) d) and store it in another variable.
nth_trm_ap = fst_trm + (total_terms - 1) * common_diff
# Print the sum and nth term of the given Arithmetic Progression series.
print("Given Arithmetic Progression Series Sum with [a,n,d]:(",
      fst_trm, total_terms, common_diff, ") = ", sum_ap)
print("The Given Arithmetic Progression Series nth Term with [a,n,d]:(",
      fst_trm, total_terms, common_diff, ") = ", nth_trm_ap)

Output:

Enter some random number = 3
Enter some random number = 9
Enter some random number = 4
Given Arithmetic Progression Series Sum with [a,n,d]:( 3 9 4 ) = 171.0
The Given Arithmetic Progression Series nth Term with [a,n,d]:( 3 9 4 ) = 35

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Find Sum of Arithmetic Progression Series Read More »

Program to Sort words in Alphabetic Order

Python Program to Sort words in Alphabetic Order

In the previous article, we have discussed Python Program to Find Longest Word from Sentence
Given a string and the task is to sort all words in a given sentence in alphabetic order.

sort() method :

By default, the sort() method sorts the list in ascending order.

split() method:

The split() method in Python divides a string into a list of strings by breaking the string with the specified separator.

Examples:

Example1:

Input:

Given String = "Hello this is btechgeeks"

Output:

The all sorted words of given sentence in Alphabetic order :
Hello
btechgeeks
is
this

Example2:

Input:

Given String = "Good morning this is btechgeeks"

Output:

The all sorted words of given sentence in Alphabetic order :
Good
btechgeeks
is
morning
this

Program to Sort words in Alphabetic Order

Below are the ways to sort all words in a given sentence in alphabetic order.

Method #1: Using sort() Method (Static Input)

Approach:

  • Give the string as static input and store it in a variable.
  • Split the given string into a list of words using the split() function and store it in another variable say “wrd_lst”.
  • Sort the above-obtained word list using the sort() method.
  • Loop in the above list “wrd_lst” using the for loop.
  • Print the iterator value to sort all words in a given sentence in alphabetic order.
  • The Exit of the Program.

Below is the implementation:

# Give the string as static input and store it in a variable.
gven_str = "Hello this is btechgeeks"
# Split the given string into list of words using the split() function and store
# it in another variable say "wrd_lst".
wrd_lst = gven_str.split()
# Sort the above obtained word list using the sort() method.
wrd_lst.sort()
# Loop in the above list "wrd_lst" using the for loop.
print("The all sorted words of given sentence in Alphabetic order :")
for wrd in wrd_lst:
  # Print the iterator value to sort all words in a given sentence in alphabetic order.
    print(wrd)

Output:

The all sorted words of given sentence in Alphabetic order :
Hello
btechgeeks
is
this

Method #2: Using sort() Method (User Input)

Approach:

  • Give the string as user input using the input() function and store it in a variable.
  • Split the given string into a list of words using the split() function and store it in another variable say “wrd_lst”.
  • Sort the above-obtained word list using the sort() method.
  • Loop in the above list “wrd_lst” using the for loop.
  • Print the iterator value to sort all words in a given sentence in alphabetic order.
  • The Exit of the Program.

Below is the implementation:

# Give the string as user input using input() function and store it in a variable.
gven_str = input("Enter some random string = ")
# Split the given string into list of words using the split() function and store
# it in another variable say "wrd_lst".
wrd_lst = gven_str.split()
# Sort the above obtained word list using the sort() method.
wrd_lst.sort()
# Loop in the above list "wrd_lst" using the for loop.
print("The all sorted words of given sentence in Alphabetic order :")
for wrd in wrd_lst:
  # Print the iterator value to sort all words in a given sentence in alphabetic order.
    print(wrd)

Output:

Enter some random string = Good morning this is btechgeeks
The all sorted words of given sentence in Alphabetic order :
Good
btechgeeks
is
morning
this

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Sort words in Alphabetic Order Read More »

Program to Calculate Sum of Series 1³+2³+3³+….+n³

Python Program to Calculate Sum of Series 1³+2³+3³+….+n³

In the previous article, we have discussed Python Program to Find Isosceles Triangle Area
The general mathematical formula to calculate the sum of cubes of a series  =  ( n (n+1) / 6)²

where n= nth term of a series.

Given the nth term of a series and the task is to calculate the sum of the cubes of a series.

Math Module :

Python’s math module is a built-in module. By importing this module, we can perform mathematical computations.

Numerous mathematical operations like ceil( ),floor( ),factorial( ),mod( ),value of pi ,…..etc .can be computed with the help of math module.

math.pow() :

The math. pow() method returns the value of x to the power of y.

It throws a ValueError if x is negative and y is not an integer.

Both arguments are converted to floats by this method.

Note: Using math.pow(1.0,x) or math.pow(x,0.0) always returns 1.0.

Examples:

Example1:

Input:

Given n value = 13

Output:

The sum of cubes of a series with the given n value[ 13 ] = 8281.0

Example2:

Input:

Given n value = 6

Output:

The sum of cubes of a series with the given n value[ 6 ] = 441.0

Program to Calculate Sum of Series 1³+2³+3³+….+n³

Below are the ways to calculate the sum of the cubes of a given series.

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Import math module using the import keyword.
  • Give the nth term of a series () as static input and store it in a variable.
  • Calculate the sum of cubes of a series with a given nth term using the above mathematical formula and math.pow() function.
  • Store it in another variable.
  • Print the sum of cubes of a given series with the given n value.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the nth term of a series as static input and store it in a variable.
num = 10
# Calculate the sum of cubes of a series with a given nth term using the above
# mathematical formula and math.pow() function. 
# Store it in another variable.
cube_sum = math.pow((num * (num + 1)) / 2, 2)
# Print the sum of cubes of a given series with the given n value.
print(
    "The sum of cubes of a series with the given n value[", num, "] =", cube_sum)

Output:

The sum of cubes of a series with the given n value[ 10 ] = 3025.0

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Import math module using the import keyword.
  • Give the nth term of a series as user input using the int(input()) function and store it in a variable.
  • Calculate the sum of cubes of a series with a given nth term using the above mathematical formula and math.pow() function.
  • Store it in another variable.
  • Print the sum of cubes of a given series with the given n value.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the nth term of a series as user input using the int(input()) function and store it in a variable.
num = int(input("Enter some random variable = "))
# Calculate the sum of cubes of a series with a given nth term using the above
# mathematical formula and math.pow() function. 
# Store it in another variable.
cube_sum = math.pow((num * (num + 1)) / 2, 2)
# Print the sum of cubes of a given series with the given n value.
print(
    "The sum of cubes of a series with the given n value[", num, "] =", cube_sum)

Output:

Enter some random variable = 8
The sum of cubes of a series with the given n value[ 8 ] = 1296.0

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Calculate Sum of Series 1³+2³+3³+….+n³ Read More »

Program to Find Volume and Surface Area of Sphere

Python Program to Find Volume and Surface Area of Sphere

In the previous article, we have discussed Python Program to Find Volume and Surface Area of a Cube
Given the radius and the task is to find the volume and surface area of the given sphere.

Surface Area of the sphere:

A sphere resembles a basketball or the three-dimensional view of a circle. If we know the radius of the Sphere,

we can use the following formula to calculate the Surface Area of the Sphere:

The Surface Area of a Sphere = 4πr²

r= radius of the given sphere

The Volume of the sphere:

Volume is the amount of space inside the sphere. If we know the radius of the sphere, we can use the following formula to calculate the volume of the sphere:

The volume of a Sphere = 4πr³

Examples:

Example 1:

Input:

Given radius = 7.5

Output:

The Surface area of the given Sphere with the radius [ 7.5 ]= 706.500
The volume of the given Sphere with the radius [ 7.5 ]= 1766.250

Example 2:

Input:

Given radius = 3

Output:

The Surface area of the given Sphere with the radius [ 3 ]= 113.040
The volume of the given Sphere with the radius [ 3 ]= 113.040

Program to Find Volume and Surface Area of Sphere

Below are the ways to find the volume and surface area of the given sphere:

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Give the radius of a sphere as static input and store it in a variable.
  • Take a variable and initialize it with the “pi” value i.e. 3.14 and store it in another variable.
  • Calculate the surface area of the given sphere using the above mathematical formula and store it in another variable.
  • Calculate the volume of the given sphere using the above mathematical formula and store it in another variable.
  • Print the surface area of the given sphere.
  • Print the volume of the given sphere.
  • The Exit of the Program.

Below is the implementation:

# Give the radius of a sphere  as static input and store it in a variable.
gvn_radis = 7.5
# Take a variable and initialize it with the "pi" value i.e. 3.14 and
# store it in another variable.
standard_pi_val = 3.14
# Calculate the surface area of the given sphere using the above mathematical formula
# and store it in another variable.
surf_area = 4 * standard_pi_val * gvn_radis * gvn_radis
# Calculate the volume of the given sphere using the above mathematical formula and
# store it in another variable.
sphre_volm = (4 / 3) * standard_pi_val * gvn_radis * gvn_radis * gvn_radis
# Print the surface area of the given sphere.
print(
    "The Surface area of the given Sphere with the radius [", gvn_radis, "]= %.3f" % surf_area)
# Print the volume of the given sphere.
print(
    "The volume of the given Sphere with the radius [", gvn_radis, "]= %.3f" % sphre_volm)

Output:

The Surface area of the given Sphere with the radius [ 7.5 ]= 706.500
The volume of the given Sphere with the radius [ 7.5 ]= 1766.250

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Give the radius of a sphere as user input using the float(input()) function and store it in a variable
  • Take a variable and initialize it with the “pi” value i.e. 3.14 and store it in another variable.
  • Calculate the surface area of the given sphere using the above mathematical formula and store it in another variable.
  • Calculate the volume of the given sphere using the above mathematical formula and store it in another variable.
  • Print the surface area of the given sphere.
  • Print the volume of the given sphere.
  • The Exit of the Program.

Below is the implementation:

# Give the radius of a sphere as user input using the float(input()) function
# and store it in a variable
gvn_radis = float(input("Enter some random variable = "))
# Take a variable and initialize it with the "pi" value i.e. 3.14 and
# store it in another variable.
standard_pi_val = 3.14
# Calculate the surface area of the given sphere using the above mathematical formula
# and store it in another variable.
surf_area = 4 * standard_pi_val * gvn_radis * gvn_radis
# Calculate the volume of the given sphere using the above mathematical formula and
# store it in another variable.
sphre_volm = (4 / 3) * standard_pi_val * gvn_radis * gvn_radis * gvn_radis
# Print the surface area of the given sphere.
print(
    "The Surface area of the given Sphere with the radius [", gvn_radis, "]= %.3f" % surf_area)
# Print the volume of the given sphere.
print(
    "The volume of the given Sphere with the radius [", gvn_radis, "]= %.3f" % sphre_volm)

Output:

Enter some random variable = 9
The Surface area of the given Sphere with the radius [ 9.0 ]= 1017.360
The volume of the given Sphere with the radius [ 9.0 ]= 3052.080

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Find Volume and Surface Area of Sphere Read More »

Program to Find Volume and Surface Area of a Cuboid

Python Program to Find Volume and Surface Area of a Cuboid

In the previous article, we have discussed Python Program to Sort words in Alphabetic Order
Cuboid:

A Cuboid is a three-dimensional object made up of six Rectangles. All of the opposing faces (Top and Bottom) are the same.

A Cuboid’s Surface Area : 

The Total Surface Area of a Cuboid is the sum of the areas of the Cuboid’s six rectangles. If we know the Cuboid’s length, width, and height, we can use the formula to calculate its Total Surface Area:

Top and bottom surface area = lw + lw = 2lw

Front and back surface area = lh + lh = 2lh

Both sides’ area = wh + wh = 2wh

A Cuboid’s Total Surface Area is the sum of its six faces. So, in order to calculate the final Surface Area, we must add all of these areas together.

A Cuboid’s Total Surface Area = 2lw + 2lh + 2wh

It is the same as:

Formula for Surface Area of a cuboid = 2 (lw + lh + wh).

A Cuboid’s Volume :
Volume is the amount of space inside the Cuboid. If we know the Cuboid’s length, width, and height, we can use the following formula to calculate its volume:

Cuboid Volume = Length * Breadth * Height

A Cuboid’s Volume = lbh

A Cuboid’s Lateral Surface Area = 2h (l + w).

Given the length, width, and height of a cuboid, the task is to calculate the volume and surface of a given cuboid.

Examples:

Example 1:

Input:

Given length = 1
Given width = 2
Given height = 3

Output:

The given surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 22.000
The given volume of a Cuboid with given length,width,height[ 1 2 3 ]= 6.000
The given lateral surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 18.000

Example 2:

Input:

Given length = 2.5
Given width = 5
Given height = 3

Output:

The given surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 70.000
The given volume of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 37.500
The given lateral surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 45.000

Program to Find Volume and Surface Area of a Cuboid

Below are the ways to calculate the volume and surface of a given cuboid.

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Give the length of a cuboid as static input and store it in a variable.
  • Give the width of a cuboid as static input and store it in another variable.
  • Give the height of a cuboid as static input and store it in another variable.
  • Calculate the surface area of a given cuboid using the above given mathematical formula and store it in another variable.
  • Calculate the volume of a given cuboid using the above given mathematical formula and store it in another variable.
  • Calculate the lateral surface area of a given cuboid using the above given mathematical formula and store it in another variable.
  • Print the surface area of a given cuboid.
  • Print the volume of a given cuboid.
  • Print the lateral surface area of a given cuboid.
  • The Exit of the Program.

Below is the implementation:

# Give the length of a cuboid as static input and store it in a variable.
gvn_len = 1
# Give the width of a cuboid as static input and store it in another variable.
gvn_widt = 2
# Give the height of a cuboid as static input and store it in another variable.
gvn_heigt = 3
# Calculate the surface area of a given cuboid using the above given mathematical formula
# and store it in another variable.
surf_area = 2 * (gvn_len * gvn_widt + gvn_len *
                 gvn_heigt + gvn_widt * gvn_heigt)
# Calculate the volume of a given cuboid using the above given mathematical formula
# and store it in another variable.
Vol = gvn_len * gvn_widt * gvn_heigt
# Calculate the lateral surface area of a given cuboid using the above given mathematical
# formula and store it in another variable.
Laterl_surfcarea = 2 * gvn_heigt * (gvn_len + gvn_widt)
# Print the surface area of a given cuboid.
print(
    "The given surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % surf_area)
# Print the volume of a given cuboid.
print(
    "The given volume of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Vol)
# Print the lateral surface area of a given cuboid.
print(
    "The given lateral surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Laterl_surfcarea)

Output:

The given surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 22.000
The given volume of a Cuboid with given length,width,height[ 1 2 3 ]= 6.000
The given lateral surface Area of a Cuboid with given length,width,height[ 1 2 3 ]= 18.000

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Give the length of a cuboid as user input using the float(input()) function and store it in a variable.
  • Give the width of a cuboid as user input using the float(input()) function and store it in another variable.
  • Give the height of a cuboid as user input using the float(input()) function and store it in another variable.
  • Calculate the surface area of a given cuboid using the above given mathematical formula and store it in another variable.
  • Calculate the volume of a given cuboid using the above given mathematical formula and store it in another variable.
  • Calculate the lateral surface area of a given cuboid using the above given mathematical formula and store it in another variable.
  • Print the surface area of a given cuboid.
  • Print the volume of a given cuboid.
  • Print the lateral surface area of a given cuboid.
  • The Exit of the Program.

Below is the implementation:

# Give the length of a cuboid as user input using the float(input()) function and
# store it in a variable.
gvn_len = float(input("Enter some random number = "))
# Give the width of a cuboid as user input using the float(input()) function and
# store it in another variable.
gvn_widt = float(input("Enter some random number = "))
# Give the height of a cuboid as user input using the float(input()) function
# and store it in another variable.
gvn_heigt = float(input("Enter some random number = "))
# Calculate the surface area of a given cuboid using the above given mathematical formula
# and store it in another variable.
surf_area = 2 * (gvn_len * gvn_widt + gvn_len *
                 gvn_heigt + gvn_widt * gvn_heigt)
# Calculate the volume of a given cuboid using the above given mathematical formula
# and store it in another variable.
Vol = gvn_len * gvn_widt * gvn_heigt
# Calculate the lateral surface area of a given cuboid using the above given mathematical
# formula and store it in another variable.
Laterl_surfcarea = 2 * gvn_heigt * (gvn_len + gvn_widt)
# Print the surface area of a given cuboid.
print(
    "The given surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % surf_area)
# Print the volume of a given cuboid.
print(
    "The given volume of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Vol)
# Print the lateral surface area of a given cuboid.
print(
    "The given lateral surface Area of a Cuboid with given length,width,height[", gvn_len, gvn_widt, gvn_heigt, "]= %.3f" % Laterl_surfcarea)

Output:

Enter some random number = 2.5
Enter some random number = 5
Enter some random number = 3
The given surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 70.000
The given volume of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 37.500
The given lateral surface Area of a Cuboid with given length,width,height[ 2.5 5.0 3.0 ]= 45.000

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Find Volume and Surface Area of a Cuboid Read More »

Program to Move all Negative Elements to End in Order with Extra Space Allowed

Python Program to Move all Negative Elements to End in Order with Extra Space Allowed

In the previous article, we have discussed Python Program to Split the Array/List and add the First Part to the End
Given a list that contains the negative and positive elements the task is to move all the negative elements to the end of the list.

Examples:

Example1:

Input:

Given List =[1, 9, -3, 6, 8, 11, 35, -5, -7, 10, -1, -2, -3]

Output:

The given list after moving negative elements to the end is [1, 9, 6, 8, 11, 35, 10, -3, -5, -7, -1, -2, -3]

Example2:

Input:

Given List = [-7 11 56 -3 -8 12 17 -25 -8 -11 -6 9 10]

Output:

The given list after moving negative elements to the end is [11, 56, 12, 17, 9, 10, -7, -3, -8, -25, -8, -11, -6]

Program to Move all Negative Elements to End in Order with Extra Space Allowed in Python

There are several ways to move all the negative elements to the end of the list some of them are:

Method #1: Using List Comprehension (Static Input)

Approach:

  • Give the list as static input and store it in a variable.
  • Using list comprehension and if conditional statements separate the positive numbers from the list and store it in a variable to say the positive list.
  • Using list comprehension and if conditional statements separate the negative numbers from the list and store it in a variable to say the negative list.
  • Add the positive list and negative list using the + operator and store it in another variable to say result list(This operation moves all the negative list).
  • Print the result list.
  • The Exit of the Program.

Below is the implementation:

# Give the list as static input and store it in a variable.
gvnlst = [1, 9, -3, 6, 8, 11, 35, -5, -7, 10, -1, -2, -3]
# Using list comprehension and if conditional statements
# separate the positive numbers from the list
# and store it in a variable to say the positive list.
pstivelist = [elemn for elemn in gvnlst if elemn >= 0]
# Using list comprehension and if conditional statements
# separate the negative numbers from the list and store it
# in a variable to say the negative list.
ngtivelist = [elemn for elemn in gvnlst if elemn < 0]
# Add the positive list and negative list using the + operator
# and store it in another variable to say result list
# (This operation moves all the negative list).
resltlist = pstivelist+ngtivelist
# Print the result list.
print('The given list after moving negative elements to the end is', resltlist)

Output:

The given list after moving negative elements to the end is [1, 9, 6, 8, 11, 35, 10, -3, -5, -7, -1, -2, -3]

Method #2: Using List Comprehension (User Input)

Approach:

  • Give the list as user input using list(),map(),input(),and split() functions.
  • Store it in a variable.
  • Using list comprehension and if conditional statements separate the positive numbers from the list and store it in a variable to say the positive list.
  • Using list comprehension and if conditional statements separate the negative numbers from the list and store it in a variable to say the negative list.
  • Add the positive list and negative list using the + operator and store it in another variable to say result list(This operation moves all the negative list).
  • Print the result list.
  • The Exit of the Program.

Below is the implementation:

# Give the list as user input using list(),map(),input(),and split() functions.
# Store it in a variable.
gvnlstt = list(map(int, input(
    'Enter some random List Elements separated by spaces = ').split()))
# Using list comprehension and if conditional statements
# separate the positive numbers from the list
# and store it in a variable to say the positive list.
pstivelist = [elemn for elemn in gvnlstt if elemn >= 0]
# Using list comprehension and if conditional statements
# separate the negative numbers from the list and store it
# in a variable to say the negative list.
ngtivelist = [elemn for elemn in gvnlstt if elemn < 0]
# Add the positive list and negative list using the + operator
# and store it in another variable to say result list
# (This operation moves all the negative list).
resltlist = pstivelist+ngtivelist
# Print the result list.
print('The given list after moving negative elements to the end is', resltlist)

Output:

Enter some random List Elements separated by spaces = -7 11 56 -3 -8 12 17 -25 -8 -11 -6 9 10
The given list after moving negative elements to the end is [11, 56, 12, 17, 9, 10, -7, -3, -8, -25, -8, -11, -6]

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Move all Negative Elements to End in Order with Extra Space Allowed Read More »

Program to Find Leaders in an ArrayList

Python Program to Find Leaders in an Array/List

In the previous article, we have discussed Python Program to Check Automorphic Number or Not
Leader:

If an element is greater than all of the elements on its right side, it is the leader. And the last element is always a leader.

Examples:

Example1:

Input:

Given list =[23, 11, 1, 7, 8, 6, 3]

Output:

The leaders of the given list [23, 11, 1, 7, 8, 6, 3] are :
23
11
8
6
3

Example2:

Input:

Given List =  [1, 2, 3, 7, 8, 6]

Output:

The leaders of the given list [1, 2, 3, 7, 8, 6] are :
8
6

Given a list, the task is to find all the leaders of the given list in python.

Program to Find Leaders in an Array/List in Python

Below are the ways to find all the leaders of the given list in python some of them are:

Method #1: Using For Loop (Static Input)

Approach:

  • Give the list as static input and store it in a variable.
  • Calculate the length of the list and store it in another variable.
  • Loop from 0 to the length of the list using the For loop.
  • Loop from parent loop iterator value to the length of the list using another Nested for loop(Inner For loop)
  • Check if the element at the index of the parent loop iterator value is less than or equal to the element at the index of the inner loop iterator value.(gvnlist [ m ] <= gvnlist [ n ] ) using the if conditional statement.
  • If it is true then break the inner loop using the break keyword.
  • After the end of the inner For loop check if the inner loop iterator value is equal to the length of the given list -1 using the if conditional statement.
  • If it is true then it is the leader so print it.
  • The Exit of the Program.

Below is the implementation:

# Give the list as static input and store it in a variable.
gvnlstt = [23, 11, 1, 7, 8, 6, 3]
# Calculate the length of the list and store it in another variable.
lstleng = len(gvnlstt)
print('The leaders of the given list', gvnlstt, 'are :')
# Loop from 0 to the length of the list using the For loop.
for m in range(lstleng):
    # Loop from parent loop iterator value to the length of the list
    # using another Nested for loop(Inner For loop)
    for n in range(m+1, lstleng):
            # Check if the element at the index of the parent loop iterator value
        # is less than or equal to the element at the index of the inner loop iterator value.
        # (gvnlist[m] <= gvnlist[n]) using the if conditional statement.
        if (gvnlstt[m] <= gvnlstt[n]):
            # If it is true then break the inner loop using the break keyword.
            break

            # After the end of the inner For loop check if the inner loop iterator value
        # is equal to the length of the given list - 1 using the if conditional statement.
    if(n == lstleng-1):
        # If it is true then it is the leader so print it.
        print(gvnlstt[m])

Output:

The leaders of the given list [23, 11, 1, 7, 8, 6, 3] are :
23
11
8
6
3

Method #2: Using For loop (User Input)

Approach:

  • Give the list as user input using list(),map(),input(),and split() functions.
  • Store it in a variable.
  • Calculate the length of the list and store it in another variable.
  • Loop from 0 to the length of the list using the For loop.
  • Loop from parent loop iterator value to the length of the list using another Nested for loop(Inner For loop)
  • Check if the element at the index of the parent loop iterator value is less than or equal to the element at the index of the inner loop iterator value.(gvnlist [ m ] <= gvnlist [ n ] ) using the if conditional statement.
  • If it is true then break the inner loop using the break keyword.
  • After the end of the inner For loop check if the inner loop iterator value is equal to the length of the given list -1 using the if conditional statement.
  • If it is true then it is the leader so print it.
  • The Exit of the Program.

Below is the implementation:

# Give the list as user input using list(),map(),input(),and split() functions.
# Store it in a variable.
gvnlstt = list(map(int, input(
    'Enter some random List Elements separated by spaces = ').split()))
# Calculate the length of the list and store it in another variable.
lstleng = len(gvnlstt)
print('The leaders of the given list', gvnlstt, 'are :')
# Loop from 0 to the length of the list using the For loop.
for m in range(lstleng):
    # Loop from parent loop iterator value to the length of the list
    # using another Nested for loop(Inner For loop)
    for n in range(m+1, lstleng):
            # Check if the element at the index of the parent loop iterator value
        # is less than or equal to the element at the index of the inner loop iterator value.
        # (gvnlist[m] <= gvnlist[n]) using the if conditional statement.
        if (gvnlstt[m] <= gvnlstt[n]):
            # If it is true then break the inner loop using the break keyword.
            break

            # After the end of the inner For loop check if the inner loop iterator value
        # is equal to the length of the given list - 1 using the if conditional statement.
    if(n == lstleng-1):
        # If it is true then it is the leader so print it.
        print(gvnlstt[m])

Output:

Enter some random List Elements separated by spaces = 1 2 3 7 8 6
The leaders of the given list [1, 2, 3, 7, 8, 6] are :
8
6

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Find Leaders in an Array/List Read More »

Program to Find Isosceles Triangle Area

Python Program to Find Isosceles Triangle Area

In the previous article, we have discussed Python Program to Find Volume and Surface Area of Sphere
Isosceles triangle :

An isosceles triangle is a triangle with two equal-length sides in geometry.It is sometimes stated as having exactly two equal-length sides and other times as having at least two equal-length sides, with the latter containing the equilateral triangle as a particular scenario.

Formula :

The formula to find the area of an isosceles triangle = (y * math.sqrt((4 * x * x) – (y * y)))/4;

where x , y are the two side lengths of an isosceles triangle.

Given two sides of an isosceles triangle and the task is to find the area of the given isosceles triangle.

Examples:

Example1:

Input:

Given length of first side = 5
Given length of second side = 9

Output:

The Given Isosceles Triangle area with sides [ 5 , 9 ]= 9.808

Example2:

Input:

Given length of first side =  12
Given length of second side = 17.2

Output:

The Given Isosceles Triangle area with sides [ 12 , 17.2 ]= 71.973

Program to Find Isosceles Triangle Area

Below are the ways to find the area of the given isosceles triangle:

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Import math module using the import keyword.
  • Give the length of the first side of an isosceles triangle as static input and store it in a variable.
  • Give the length of the second side of an isosceles triangle as static input and store it in another variable.
  • Calculate the length of the given isosceles triangle using math.sqrt() function and the above given mathematical formula.
  • Store it in another variable.
  • Print the area of the given isosceles triangle.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the length of the first side of an isosceles triangle as static input
# and store it in a variable.
fst_side = 5
# Give the length of the second side of an isosceles triangle as static input
# and store it in another variable.
secnd_side = 9
# Calculate the length of the given isosceles triangle using math.sqrt() function
# and the above given mathematical formula.
# Store it in another variable.
area_isosce_tringl = (
    secnd_side * math.sqrt((4 * fst_side * fst_side) - (secnd_side * secnd_side)))/4
# Print the area of the given isosceles triangle.
print("The Given Isosceles Triangle area with sides [",
      fst_side, ",", secnd_side, "]= %.3f" % area_isosce_tringl)

Output:

The Given Isosceles Triangle area with sides [ 5 , 9 ]= 9.808

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Import math module using the import keyword.
  • Give the length of the first side of an isosceles triangle as user input using the float(input()) function and store it in a variable.
  • Give the length of the second side of an isosceles triangle as user input using the float(input()) function and store it in another variable.
  • Calculate the length of the given isosceles triangle using math.sqrt() function and the above given mathematical formula.
  • Store it in another variable.
  • Print the area of the given isosceles triangle.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the length of the first side of an isosceles triangle as user input using the float(input()) 
#function and store it in a variable.
fst_side = float(input("Enter some random number = "))
# Give the length of the second side of an isosceles triangle as user input using the float(input())
#function and store it in another variable.
secnd_side =  float(input("Enter some random number = "))
# Calculate the length of the given isosceles triangle using math.sqrt() function
# and the above given mathematical formula.
# Store it in another variable.
area_isosce_tringl = (
    secnd_side * math.sqrt((4 * fst_side * fst_side) - (secnd_side * secnd_side)))/4
# Print the area of the given isosceles triangle.
print("The Given Isosceles Triangle area with sides [",
      fst_side, ",", secnd_side, "]= %.3f" % area_isosce_tringl)

Output:

Enter some random number = 15
Enter some random number = 22.5
The Given Isosceles Triangle area with sides [ 15.0 , 22.5 ]= 111.618

The area is isosceles is calculated by the above formula.

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Find Isosceles Triangle Area Read More »

Python Program to Find Volume and Surface Area of a Cube

In the previous article, we have discussed Python Program to Find Sum of Arithmetic Progression Series
Surface Area of a Cube :

If we know the length of an edge in a Cube, we can use the following formula to calculate the surface area of a Cube:

Cube Surface Area = 6S²

In which  S= length of any side of a Cube

A square’s area = S². Surface Area of a Cube = 6S²  because the Cube is made up of 6 equal squares.

The volume of a Cube :

Volume refers to the amount of space inside the Cube. If we know the length of any edge of a Cube, we can use the following

Formula to calculate the Volume of the Cube:  S*S*S*

A Cube’s Lateral Surface Area = 4 * (S * S)
Given the side of a cube and the task is to find the surface area, volume, and lateral surface for a given side of a cube.

Examples:

Example 1:

Input:

Given side length of a cube = 12

Output:

The given surface Area of a Cube with side length [ 12 ]= 864.000
The given volume of a Cube with side length [ 12 ]= 1728.000
The given lateral surface area of a Cube with side lngth [ 12 ]= 576.000

Example 2:

Input:

Given side length of a cube = 4

Output:

The given surface Area of a Cube with side length [ 4 ]= 96.000
The given volume of a Cube with side length [ 4 ]= 64.000
The given lateral surface area of a Cube with side lngth [ 4 ]= 64.000

Program to Find Volume and Surface Area of a Cube in Python

Below are the ways to find the surface area, volume, and lateral surface for a given side of a cube:

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Give the length of the side of a cube as static input and store it in a variable.
  • Calculate the surface area of a given cube using the above given mathematical formula and store it in another variable.
  • Calculate the volume of a given cube using the above given mathematical formula and store it in another variable.
  • Calculate the lateral surface area of a given cube using the above given mathematical formula and store it in another variable.
  • Print the surface area of a given cube.
  • Print the volume of a given cube.
  • Print the lateral surface area of a given cube.
  • The Exit of the Program.
 Below is the implementation:
# Give the length of the side of a cube as static input and store it in a variable.
cube_side = 7
# Calculate the surface area of a given cube using the above given mathematical formula
# and store it in another variable.
surf_area = 6 * (cube_side * cube_side)
# Calculate the volume of a given cube using the above given mathematical formula and
# store it in another variable.
Volum = cube_side * cube_side * cube_side
# Calculate the lateral surface area of a given cube using the above given mathematical
# formula and store it in another variable.
Laterl_surfcarea = 4 * (cube_side * cube_side)
# Print the surface area of a given cube.
print(
    "The given surface Area of a Cube with side length [", cube_side, "]= %.3f" % surf_area)
# Print the volume of a given cube.
print(
    "The given volume of a Cube with side length [", cube_side, "]= %.3f" % Volum)
# Print the lateral surface area of a given cube.
print(
    "The given lateral surface area of a Cube with side lngth [", cube_side, "]= %.3f" % Laterl_surfcarea)

Output:

The given surface Area of a Cube with side length [ 7 ]= 294.000
The given volume of a Cube with side length [ 7 ]= 343.000
The given lateral surface area of a Cube with side lngth [ 7 ]= 196.000

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Give the length of the side of a cube as user input using the float(input()) function and store it in a variable.
  • Calculate the surface area of a given cube using the above given mathematical formula and store it in another variable.
  • Calculate the volume of a given cube using the above given mathematical formula and store it in another variable.
  • Calculate the lateral surface area of a given cube using the above given mathematical formula and store it in another variable.
  • Print the surface area of a given cube.
  • Print the volume of a given cube.
  • Print the lateral surface area of a given cube.
  • The Exit of the Program.

 Below is the implementation:

# Give the length of the side of a cube as user input using the float(input()) function
# and store it in a variable.
cube_side = float(input("Enter some random number = "))
# Calculate the surface area of a given cube using the above given mathematical formula
# and store it in another variable.
surf_area = 6 * (cube_side * cube_side)
# Calculate the volume of a given cube using the above given mathematical formula and
# store it in another variable.
Volum = cube_side * cube_side * cube_side
# Calculate the lateral surface area of a given cube using the above given mathematical
# formula and store it in another variable.
Laterl_surfcarea = 4 * (cube_side * cube_side)
# Print the surface area of a given cube.
print(
    "The given surface Area of a Cube with side length [", cube_side, "]= %.3f" % surf_area)
# Print the volume of a given cube.
print(
    "The given volume of a Cube with side length [", cube_side, "]= %.3f" % Volum)
# Print the lateral surface area of a given cube.
print(
    "The given lateral surface area of a Cube with side lngth [", cube_side, "]= %.3f" % Laterl_surfcarea)

Output:

Enter some random number = 5.5
The given surface Area of a Cube with side length [ 5.5 ]= 181.500
The given volume of a Cube with side length [ 5.5 ]= 166.375
The given lateral surface area of a Cube with side lngth [ 5.5 ]= 121.000

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Find Volume and Surface Area of a Cube Read More »

Program to Find Volume and Surface Area of a Cone

Python Program to Find Volume and Surface Area of a Cone

In the previous article, we have discussed Python Program to Calculate Sum of Series 1³+2³+3³+….+n³
The surface area of a cone : 

Formula to calculate its surface area:
Surface Area = Area of a Cone + Area of a Circle
i.e. Surface Area of cone = πrl + πr²
In which  ‘r’ denotes radius and

‘l’ denotes slant (Length of an edge from the top of the cone to edge of a cone)

If we know the radius and height of a cone, we can use the following formula to calculate its surface area:
Surface Area = πr² +πr √h² + r²
It can also be written as:
Surface Area of a cone =  πr (r+√h² + r²)

Because the radius, height, and slant combine to form a right-angled triangle. So, using Pythagoras’ theorem:

l² = h² + r²
l = √h² + r²

The volume of a cone :

Volume refers to the amount of space inside the Cone. If we know the radius and height of the cone, we can use the following formula to calculate the volume:
The volume of a cone= 1/3 πr²h  (where h = height of a cone)

A Cone’s Lateral Surface Area = Ï€rl

Given the radius and height of a cone, the task is to find the surface area, volume, and lateral surface for a given cone.

Examples:

Example 1:

Input:

Given radius = 6.5
Given height = 10

Output:

The given cone's slant height = 11.927
The given surface Area of a cone with given radius,height[ 6.5 10 ]= 376.283
The given volume of a cone with given radius,height[ 6.5 10 ]= 442.441
The given lateral surface Area of a cone with given radius,height[ 6.5 10 ]= 243.551

Example 2:

Input:

Given radius =  4
Given height = 8

Output:

The given cone's slant height = 8.944
The given surface Area of a cone with given radius,height[ 4 8 ]= 162.663
The given volume of a cone with given radius,height[ 4 8 ]= 134.041
The given lateral surface Area of a cone with given radius,height[ 4 8 ]= 112.397

Program to Find Volume and Surface Area of a Cone

Below are the ways to find the surface area, volume, and lateral surface for a given cone.

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Import math module using the import keyword.
  • Give the radius of a cone as static input and store it in a variable.
  • Give the height of a cone as static input and store it in another variable.
  • Calculate the Slant height of a given cone using the above given mathematical formula and math.sqrt() function and store it in another variable.
  • Calculate the surface area of a given cone using the above given mathematical formula and math.pi function
  • Store it in another variable.
  • Calculate the volume of a given cone using the above given mathematical formula and math.pi function
  • Store it in another variable.
  • Calculate the lateral surface area of a given cone using the above given mathematical formula and math.pi function.
  • Store it in another variable.
  • Print the slant height of a given cone.
  • Print the surface area of a given cone.
  • Print the volume of a given cone.
  • Print the lateral surface area of a given cone.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the radius of a cone as static input and store it in a variable.
gvn_rad = 6.5
# Give the height of a cone as static input and store it in another variable.
gvn_heigt = 10
# Calculate the Slant height of a given cone using the above given mathematical formula
# and math.sqrt() function and store it in another variable.
slant_l = math.sqrt(gvn_rad * gvn_rad + gvn_heigt * gvn_heigt)
# Calculate the surface area of a given cone using the above given mathematical formula and math.pi function
# Store it in another variable.
surf_area = math.pi * gvn_rad * (gvn_rad + slant_l)
# Calculate the volume of a given cone using the above given mathematical formula and
# math.pi function
# Store it in another variable.
Vol = (1.0/3) * math.pi * gvn_rad * gvn_rad * gvn_heigt
# Calculate the lateral surface area of a given cone using the above given mathematical
# formula and math.pi function.
# Store it in another variable.
Laterl_surfcarea = math.pi * gvn_rad * slant_l
# Print the slant height of a given cone.
print("The given cone's slant height = %.3f" % slant_l)
# Print the surface area of a given cone.
print(
    "The given surface Area of a cone with given radius,height[", gvn_rad, gvn_heigt, "]= %.3f" % surf_area)
# Print the volume of a given cone.
print(
    "The given volume of a cone with given radius,height[", gvn_rad, gvn_heigt, "]= %.3f" % Vol)
# Print the lateral surface area of a given cone.
print(
    "The given lateral surface Area of a cone with given radius,height[", gvn_rad, gvn_heigt, "]= %.3f " % Laterl_surfcarea)

Output:

The given cone's slant height = 11.927
The given surface Area of a cone with given radius,height[ 6.5 10 ]= 376.283
The given volume of a cone with given radius,height[ 6.5 10 ]= 442.441
The given lateral surface Area of a cone with given radius,height[ 6.5 10 ]= 243.551

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Import math module using the import keyword.
  • Give the radius of a cone as user input using the float(input()) function and store it in a variable.
  • Give the height of a cone as user input using the float(input()) function and store it in another variable.
  • Calculate the Slant height of a given cone using the above given mathematical formula and math.sqrt() function and store it in another variable.
  • Calculate the surface area of a given cone using the above given mathematical formula and math.pi function
  • Store it in another variable.
  • Calculate the volume of a given cone using the above given mathematical formula and math.pi function
  • Store it in another variable.
  • Calculate the lateral surface area of a given cone using the above given mathematical formula and math.pi function.
  • Store it in another variable.
  • Print the slant height of a given cone.
  • Print the surface area of a given cone.
  • Print the volume of a given cone.
  • Print the lateral surface area of a given cone.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the radius of a cone user input using the float(input()) function and store it in a variable.
gvn_rad = float(input("Enter some random number = "))
# Give the height of a cone user input using the float(input()) function and store it in another variable.
gvn_heigt = float(input("Enter some random number = "))
# Calculate the Slant height of a given cone using the above given mathematical formula
# and math.sqrt() function and store it in another variable.
slant_l = math.sqrt(gvn_rad * gvn_rad + gvn_heigt * gvn_heigt)
# Calculate the surface area of a given cone using the above given mathematical formula and math.pi function
# Store it in another variable.
surf_area = math.pi * gvn_rad * (gvn_rad + slant_l)
# Calculate the volume of a given cone using the above given mathematical formula and
# math.pi function
# Store it in another variable.
Vol = (1.0/3) * math.pi * gvn_rad * gvn_rad * gvn_heigt
# Calculate the lateral surface area of a given cone using the above given mathematical
# formula and math.pi function.
# Store it in another variable.
Laterl_surfcarea = math.pi * gvn_rad * slant_l
# Print the slant height of a given cone.
print("The given cone's slant height = %.3f" % slant_l)
# Print the surface area of a given cone.
print(
    "The given surface Area of a cone with given radius,height[", gvn_rad, gvn_heigt, "]= %.3f" % surf_area)
# Print the volume of a given cone.
print(
    "The given volume of a cone with given radius,height[", gvn_rad, gvn_heigt, "]= %.3f" % Vol)
# Print the lateral surface area of a given cone.
print(
    "The given lateral surface Area of a cone with given radius,height[", gvn_rad, gvn_heigt, "]= %.3f " % Laterl_surfcarea)

Output:

Enter some random number = 4.5
Enter some random number = 2
The given cone's slant height = 4.924
The given surface Area of a cone with given radius,height[ 4.5 2.0 ]= 133.235
The given volume of a cone with given radius,height[ 4.5 2.0 ]= 42.412
The given lateral surface Area of a cone with given radius,height[ 4.5 2.0 ]= 69.617

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Python Program to Find Volume and Surface Area of a Cone Read More »