Posts

How to display BMI(Body mass index )using python program

Image
 BODY MASS INDEX Body Mass Index (BMI) is a person’s weight in kilograms (or pounds) divided by the square of height in meters (or feet). A high BMI can indicate high body fatness.  CODING OF THE PROGRAM Height= float ( input (" Enter the height in cm: ")) Weight= float ( input (" Enter your weight in kg: ")) BMI=Weight/ (Height/100)**2 print(" Your Body mass index is ",BMI) if BMI<=18.4:         print (" You are under weigh ") elif   BMI<=24.9:         print (" Congratulations! You are Healthy ") elif BMI<=29.9:               print (" You are overweigh ") else :         print (" You are Obese ") OUTPUT OF THE PROGRAM                                                                    THANK YOU😊

Program to find out whether a given number is prime number or not in python[using break statement]

Image
PRIME NUMBER OR COMPOSITE NUMBER Prime and composite numbers  are the two types of numbers, that differ based on the number of factors they have.  A prime number is the one that has only two factors . A composite number has more than two factors.  A  factor  is a value, that can divide a number or an expression evenly. A prime number is the one which has exactly two factors, which means, it can be divided by only “1” and itself. But “1” is not a prime number. A composite number has more than two factors, which means apart from getting divided by the number 1 and itself, it can also be divided by at least one integer or number. We don’t consider ‘1’ as a composite number. CODING OF THE PROGRAM num= int ( input (" Enter a number to check ")) for i in range (2,num):         if   num%i==0:               print (num," is a Composite  number ")               break else...

To display whether the given number is perfect or not in Python

Image
 PERFECT NUMBER Perfect number , a positive  integer  that is equal to the sum of its proper divisors. The smallest perfect number is 6, which is the sum of 1, 2, and 3. Other perfect numbers are 28, 496, and 8,128. CODING OF THE PROGRAM num= int ( input (" Enter a number to check ")) divsum=0 for i in range (1,num):        if num%i==0:               divsum=divsum+i if divsum==num:         print (num, " is a perfect number ") else :         print (num, " is not a perfect number ") OUTPUT  OF THE PROGRAM IN PYTHON                                                  THANK YOU😊

How to display Floyd's triangle in python program

Image
FLOYD'S TRIANGLE Floyd's triangle  is a  triangular  array of  natural numbers , used in computer science education. It is named after  Robert Floyd . It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner. ROBERT W. FLOYD Born -  June 8, 1936 Died -  September 25, 2001  (aged 65) Robert W Floyd   was a  computer scientist . His contributions include the design of the  Floyd–Warshall algorithm  (independently of  Stephen Warshall ), which efficiently finds all shortest paths in a  graph ,  Floyd's cycle-finding algorithm  for detecting  cycles  in a sequence, and his work on  parsing . In one isolated paper he introduced the important concept of error diffusion for rendering images, also called  Floyd–Steinberg dithering  (though he distinguished dithering from diffusion). He pioneered in the field of  program ...

To Find whether the given number is a palindrome number or not in python

Image
  PROGRAM CODING  num= int ( input ("Enter a number")) revnum=0 cnum=num while   num>0:        revnum=revnum*10+num%10        num=num//10 if revnum==cnum:        print("The given number is a palindrome number") else:        print("The given number is not a palindrome number") EXPLANATION OF THE PROGRAM revnum mean reverse of a number, whatever we give it will work but as a appropriate meaning revnum is correct cnum is copy of the number   // - Floor division First you have to give a number, input will take it as a string and int will change the string into integer. We are associating 0(zero) to revnum And then we took a copy of the num as cnum while num>0 : is a condition when it becomes true the following loop will be executed

How to Display the statistics in the given string using Python

STATISTICS CODING OF THE PROGRAM msg= input (" Enter a string  ") v,c,u,l,s=0,0,0,0,0 for ch in msg:        if ch.isupper( ):               u=u+1        if ch.islower( ):               l=l+1        if ch in" AEIOUaeiou ":               v=v+1        if ch.isspace( ):               s=s+1        if ch.isalpha and ch not in " AEIOUaeiou ":               c=c+1 print (''' Given string "%s" contains %d vowels %d consonants %d uppercase characters %d lowercase characters %d space '''%(msg,v,c,u,l,s)) OUTPUT OF THE PROGRAM Enter a string God is Great Given string "God is Great" contains 4 vowels 8 consonants 2 uppercase characters 8 lowercase characters 2 space