Skip to main content

Posts

Showing posts with the label Programs

Python Program to Count Number Of Occurances of character

Python Program to  Count Number Of Occurances of character       Input:      Program        r      Out put:           2                  Code:          S=input()          c=input()           count=0;           for i in S:               if c==i:                    count+=1           print(count)             Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to Generate a Random Number

                 Python Program to  Generate a Random Number       Input:        None      Out put:           2                  Code:          import random           print(random.randint(0,9))           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to Find Square Root Of A Number

               Python Program to  Find Square Root Of A Number       Input:         4      Out put:           2            Explanation :                    Generally squareroot(4)=2                   Code:          number=int(input())           print(number**0.5)           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to Check whether a character is a Vowel or Consonant

                  Python Program to Check whether a character is a Vowel or Consonant   In this we are going to learn given character is vowel or Consonant. Generally there are 5 vowels they are a,e,i,o,u and remaining are the consonants in alphabets of 26. we can write this program by using strings. string is a collection of characters.         Input:        k      Out put:           Consonant                Explanation :             vowels={a,e,i,o,u,A,E,I,O,U}          if input character in the above list then vowels, else consonant                   Code:         r=input()       # input string         s="aeiou"    ...

Python Program to Convert Decimal to Binary

                Python Program to Convert Decimal to Binary      In this program we are going to learn how to convert decimal number (base 10) to binary number (base 2). In this program we use bin method for converting decimal to binary number (0 or 1).       Input:          2      Out put:            10      Explanation :                     2(base 10) = 10 (base 2)               generally it was done by dividing 2 with given decimal value and take remainders from bottom to up.                             Code:          r=int(input())           print(bin(r)[2:])       ...

Python Program to Convert Radians into Degrees

               Python Program to Convert Radians into Degrees     In this we are going to learn how to convert radians into degrees. Generally 1 radian=57.2958 degrees. In this program we use round function to round decimal values 3.         Input:          2        Out put:           114.592                  Explanation :          1 radian = 57.2958 degrees          2 radians = 2*57.2958 = 114.592 degrees                   Code:          r=int(input())           print(round(r*57.2958,3))           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to check given year is leap year or not?

              Python Program to check given year is leap year or not?     In this we are going to check given year is leap year or not. Generally Leap years are comes every 4 years from starting. Leap year contains 366 days (365+1) . We define a leapyear is divisible by 4 then leap year.       Input:          2000      Out put:            Leap year                Explanation :          2000%4 = 0 then it is leap year                   Code:          year=int(input())           if(year%400):               print("Leap year")          elif(year%100):               print("N...

Python Program to Convert Hectare to Acre

             Python Program to Convert Hectare to Acre       Generally 1 hectare = 2.471 acres. It is used find the area of the lands or farming. It is comes under unit conversions.       Input:          1      Out put:           2.471044            Explanation :                    Generally 1 hectare = 2.471044 acres                       Code:          hectare=int(input())           print(hectare*2.471044)           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to Convert Inches to Centimeters

            Python Program to Convert Inches to Centimeters           Generally 1 inch = 2.540 centimeters. It is comes under unit conversions. In this program we converting the inches to centimeters.       Input:          1      Out put:                      2.540               Explanation :                      1 inch = 2.540 centimeters then the answer will be 2.540        Code:          inches=int(input())           print(inches*2.540)           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to Convert hours into seconds

           Python Program to Convert hours into seconds             Generally 1 hour has 60 minutes. 1 minute has 60 seconds. In the solution we multiply value with 60*60 because of  above values. Then the code is given below that converts hours into seconds.           Input:          2       Out put:                     7200            Explanation :                     1 hour = 60 minutes, 1 minute = 60 seconds then          2*60*60 = 7200 seconds.                   Code:          hours=int(input())           print(hours*60*60)           N...

Python Program to find Perimeter of a rectangle

          Python Program to find Perimeter of a rectangle    perimeter of the rectangle = 2*(l+b) l = length of a rectangle b = breadth of the rectangle In this program we are going to find the perimeter of the rectangle by using formula. This is the one way to find the perimeter of a rectangle        Input:          6 7      Out put:            26      Explanation :                 l = 6 , b = 7          perimter of rectangle = 2*( l +b ) = 2*( 6 + 7 ) = 26        Code:          length, width = map( int, input().split())           print(2 * ( length + width))           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to find Area of a triangle

          Python Program to find Area of a triangle     Hint:                                                                      Area of traingle= 1/2bh                                                                      b=breadth of a triangle                                                                      h=height of a triangle   I...

Python Program to find length of a number

         Python Program to find length of a number     In this post we are going to find the length of a number. For example length of 100 is 3. In this way we have to find solution for the above program.     Input:          5000      Out put:            4      Explanation :          length ( 5000 ) = 4 its 4.          Code:          n=input()           print(len(n))           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to find minimum and maximum elements in the array

        Python Program to find minimum and maximum elements in the array     A number which is less than other number is said as minimum number and another number is called as maximum number. In this post we are going to write solution for minimum nd maximum element in the array      Input:          1 2 3 4      Out put:            minimum element=1          maximum element=4      Explanation:          [1,2 ,3 ,4]          min = 1 , max =4        Code:          arr=list(map(int,input().split()))           print("minimum element=",min(arr))          print("maximum element=",max(arr))           Note:     Hello Guys, Don't Stop Learning keep Goin...

Python Program to find sum of array of elements

       Python Program to find sum of array of elements    Array is a collection of similar datatype which are stored in sequencial order. In this post we are going to find sum of the array elements in the array or list.      Input:          1 2 3 4      Out put:            10      Explanation :           [1,2,3,4]          sum = 1 + 2 + 3 +4 = 10 (desired output).        Code:          arr=list(map(int,input().split()))           print(sum(arr))           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to find ascii value of a character

      Python Program to find ascii value of a character   Ascii is american standard code for information interchange. It is a character encoding standard. This ascii code is used to represent text in computer. In this post we are going to learn how to find ascii value of a character.       Input:          a      Out put:            ascii value of a is 97        Code:          r=input()           print("ascii value of "+r+" is  ",ord(r) )           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to find area of a circle

     Python Program to find area of a circle                                 Area of a circle =  πr 2                                             r = radius of a circle  To find area of a circle we need to follow the formula. Area of a circle is  π r 2  . r is the radius of a circle.            Input:          5      Out put:            area of a circle is 78.5      Explanation :          r = 5,  π = 3.14     area of a circle= 3.14*(r*r) = 3.14*5*5 = 78.5         Code:          r=input()        ...

Python Program to check given number is palindrome or not

    Python Program to check given number is palindrome or not?     A palindrome number is a number that remains same when digits its are reversed. example for the palindrome number is 121. this number same as both sides then it called as palindrome. In this post we are going to learn given number is palindrome or not.      Input:          121      Out put:            Palindrome      Explanation :           121 is same as both sides then it called as palindrome.        Code:          n=input()          if(n==n[::-1]):               print("palindrome")          else:               print("not palindrome")                ...

Python Program to find compound Interest

    Python Program to find Compound Interest      Input:          1200          5.4          2      Out put:            Compound interest is 1333.0992        Code:               p=float(input())                      r=float(input())                       t=float(input())                       x=p*(1+r/100)**t                       print("Compound interest is ",x)    Note:     Hello Guys, Don't Stop Learning keep Going..............

Python program to calculate BMI

   Program to find BMI(body  mass index )      Input:          60          5.1      Out put:            BMI index is 23.53       Code:                      h=int(input())                       w=int(input())                       x=w/h*2                       print("BMI index is ",x)      Note:     Hello Guys, Don't Stop Learning keep Going..............