Find the sum of numbers in a given range In Python

     

         Find the sum of numbers in a given range In Python

Program:

    startnum = int(input("Enter Start Number" ))
    endnum = int(input("Enter Ending Number"))
    sum = 0
    for i in range(startnum, endnum + 1, 1):
    sum = sum + i
    print(sum)


    OutPut:
    Enter Start Number1
    Enter Ending Number10
    55

    Enter Start Number20
    Enter Ending Number30
    275

    Find Number of digits in Given Number In Python

        

    Find Number of digits in Given Number  In Python 


    Program:


    n = int(input("Enter a number : "))
    count = 0
    while(n != 0):
        n = int(n/10)
        count = count + 1
    print("Number of digits in Given Number is :",count)



    OutPut:
    Enter a number : 1224
    Number of digits in Given Number is : 4







    find the largest among three numbers In Python

       

    find the largest among three numbers  In Python 


    Program:


    a = int(input("Enter A"))
    b = int(input("Enter B"))
    c = int(input("Enter C"))
    if(a > b and a > c):
        print("A is Max")
    elif(b > c and b > c):
        print("B is Max")
    else:
        print("C is Max")
        



    OutPut:
    Enter A 12
    Enter B 45
    Enter C 6

    B is Max


    For More Information Visit: http://msktutorials.com/





    LCM of two numbers In Python

          

    LCM of two numbers In Python 


    The Least Common Multiple (LCM) of a group of numbers is the smallest number that is a multiple of all the numbers.

    Program:

    a = int(input("Enter FIrst numbers"))
    b = int(input("Enter Second numbers"))
    lc = 0
    if(a > b):
     lcm = a
    else:
     lc = b
    while(1):
     if( lc % a == 0 and lc % b == 0 ):
       print("LCM of",a,"and",b,"is",lc)
     break
     lc = lc + 1



    OutPut:
    Enter FIrst numbers7
    Enter Second numbers21
    LCM of 7 and 21 is 21

    Python program to check whether the character is an alphabet or not

         

    Python program to check whether the character is an alphabet or not 


    Program:

    ch=input("Enter any character:")
    if((ch>='a' and ch<='z') or (ch>='A' and ch<='Z')):
        print(ch," is an alphabet")
    else:
      
        print(ch,"is not an alphabet")



    OutPut:
    Enter any character:2
    2 is not an alphabet

    Enter any character:d
    d  is an alphabet






    Python Program to Calculate the Power of a Number

        

       Python Program to Calculate the Power of a Number 


    Program:

    result = 1;
    base=int(input("Enter a base number: "))
        
    exp=int(input("Enter an exponent: "))

    while (exp != 0):
            result *= base;
            exp=exp-1;
    print("Answer =", result);



    OutPut:
    Enter a base number: 3
    Enter an exponent: 4
    Answer = 81

    Enter a base number: 2
    Enter an exponent: 3
    Answer = 8







    GCD Using While Loop In Python

       

       GCD Using While Loop In Python 

    The HCF or GCD of two integers is the largest integer that can exactly divide both numbers (without a remainder).

    GCD: greatest common divisor 


    Program:

    n1=int(input("Enter n1 integer: "))
    n2=int(input("Enter n2 integer: "))       
        
    while(n1!=n2):

            if(n1 > n2):
                n1 -= n2;
            else:
                n2 -= n1;

    print("GCD = ",n1);


    OutPut:
    Enter n1 integer: 81
    Enter 21 integer: 153
    GCD =  9








    Reverse number without recursion in Python

      

             Reverse number  in Python 

    Python program to reverse a number and to print it on the screen. For example, if the input is 123, the output will be 321

    Sum of digits program in Python

        

             Sum of digits program in Python

    Program:

      sum=0;m=0;    
        n=int(input("Enter a number:"))       
          while(n>0):   
                m=n%10;    
                  sum=sum+m;    
                    n=n//10;     
                  print("Sum is ",sum)


                  OutPut:
                  Enter a number:654
                  Sum is  15

                  Enter a number:123
                  Sum is  6

                  Factorial Program using recursion in Python

                     

                           Factorial Program using recursion in Python

                  Factorial of n is the product of all positive descending integers. Factorial of n is denoted by n!. For example:

                  1. 5! = 5*4*3*2*1 = 120  
                  2. 3! = 3*2*1 = 6  

                  Factorial Number Program in Python

                    

                           Factorial Number Program in Python

                  Factorial of n is the product of all positive descending integers. Factorial of n is denoted by n!. For example:

                  1. 5! = 5*4*3*2*1 = 120  
                  2. 3! = 3*2*1 = 6  

                  Prime Number Program in Python

                   

                           Prime Number Program in Python

                  Prime number in C: Prime number is a number that is greater than 1 and divided by 1 or itself. In other words, prime numbers can't be divided by other numbers than itself or 1. For example 2, 3, 5, 7, 11, 13, 17, 19, 23.... are the prime numbers.

                  Check Leap Year in Python

                   

                           Check Leap Year  In Python

                  Check if a Number is Palindrome or Not in Python

                           Check if a Number is Palindrome or Not in Python

                  A palindromic number is a number that remains the same when its digits are reversed. In other words, it has reflectional symmetry across a vertical axis. The term palindromic is derived from palindrome, which refers to a word whose spelling is unchanged when its letters are reversed.

                  Fibonacci Series in Python

                     

                           Fibonacci Series in Python 

                  Fibonacci Sequence. The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2​, 3, 5, 8, 13, 21, 34, ... 

                  Reverse number using Recursion in Python

                    

                           Reverse number using Recursion in Python 

                  Python program to reverse a number and to print it on the screen. For example, if the input is 123, the output will be 321

                  Check Armstrong Number in Python

                   

                           Check Armstrong Number in Python

                  An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 153  is an Armstrong

                  Palindrome Numbers in a Given Range in Python

                           Palindrome Numbers in a Given Range in Python

                  A palindromic number is a number that remains the same when its digits are reversed. In other words, it has reflectional symmetry across a vertical axis. The term palindromic is derived from palindrome, which refers to a word whose spelling is unchanged when its letters are reversed.