Python program to calculate the volume of a sphere

In this python basic program, we will calculate the volume of a sphere using the formula (4/3*pi*r^2).

Steps to solve the program
  1. Take radius as input through the user.
  2. Calculate the volume of a sphere using the formula (4/3*pi*r^2).
  3. Where pi is equal to 3.14 and r is the radius of the sphere.
  4. Print the output.

Output :

find the square root of a number.

perform mathematical operations on two numbers.

Python program to find the LCM of two numbers.

In this python basic program, we will find the LCM two numbers defined by the user.

Steps to solve the program
  1. Take two numbers as input through the user.
  2. Using an if-else statement check which number is greater
  3. Use While loop.
  4. Inside the While loop check whether both numbers divide the greater number or not.
  5. If yes then break the loop otherwise, add 1 to the greater number and let the loop continue.
  6. At the end print the output.

Output :

Program to find HCF

find the square root of a number.

Python program to find HCF of two numbers.

In this python basic program, we will find the HCF of two numbers defined by users.

Steps to solve the program
  1. Take two numbers as input through the user.
  2. Using an if-else statement check which number is smaller.
  3. Use for loop with the range function to iterate over numbers from 1 to the smaller number.
  4. During iteration check whether the iterated number divides both input numbers, if yes then assign that number to the variable.
  5. After the loop is finished print the output.

Output :

find the sum of natural numbers.

Program to find LCM

Python program to find the sum of natural numbers.

In this python basic program, we will find the sum of natural numbers defined by the user.

Steps to solve the program
  1. Take the last number up to which you want to find the sum as input through the user.
  2. Create a variable to store the sum and assign its value equal to 0.
  3. Use for loop with the range function to iterate over natural numbers defined by the user.
  4. During iteration add the respective natural number to the variable that we have created to find the sum.
  5. Print the output.

Output :

convert Decimal to Binary.

Program to find HCF

Generate a random string with a specific length.

In this python basic program, we will generate a random string with a specific length.

Steps to solve the program
  1. Import string and random library.
  2. Take the length of the string as input through the user.
  3. To generate random string with a specified length use random.choices(string.ascii_letters, k=n), where n is the length.
  4. Print the output.

Output :

generate random numbers.

get the current date.

Program to generate random numbers.

In this python basic program, we will generate random numbers using random library.

Steps to solve the program
  1. Import random library.
  2. We are going to generate 5 random numbers, so use for loop with range function to generate 5 number.
  3. Use random.random() to generate random numbers inside the loop.
  4. Print the output.

Output :

check for the anagram.

generate a random string with a specific length.