Binary to decimal in python with source code | Python Project | Total Tech

Binary to decimal in python with source code | Python Project | Total Tech

Binary to decimal in python with source code | Python Project


    Introduction About Project

    Hi, Guys, I am gone to give you a creative Python project. From that project, you will know about your skills that you achieved by spending time in python. This project is not difficult but still, this is the best project for beginners. I will expect that you do this project yourself and give your full efforts on this project.

    What is the project and how to get the source code of that project?

    The project that I will talk about is binary to decimal in python converter which is the most unique project of python and you can easily do this project. In that project, you have to take input from a user as a binary number then you will give an output as a decimal number.


    Now, we will talk about how to get the source code of that project for that you have to read this article fully than at the last of that article you will get a Source code of binary to decimal in python project where you can copy that code and paste it in your text editor or IDE. 


    But still, I expect to use that you did not want that source code and you will try to do this binary to decimal in python project by yourself without seeing this source code then at the last your project was done you can see that source code then you can find errors and you can improve yourself.


    What are Binary Numbers and Decimal Numbers?

    Before you go for this project you first know what binary numbers and decimal numbers are, so let's see what is a binary number then we will talk about decimal numbers.


    The binary number is written in the form of 0 and 1, this number is understandable by computers and machines. Each decimal number has a different binary number. For example - We convert the Decimal number 25 to a binary number is 11001.


    Now let's see what is Decimal number. The numbers that are used in your normal daily life are those numbers called decimal numbers. In the school day in smaller classes, we also learn decimal numbers. The example of a decimal number is 62.


    Source Code

    
    
    
    # Taking value from the user 
    val = input('Enter your binary number which you want to convert into number: ')
    
    # Create Some Helping Variables
    digit = []
    a=1
    b = [1]
    c=1
    e = []
    
    # Split the binary Number in list in the digit Form 
    for value in val:
        digit.append(int(value))
    
    # We Store the Number of digit in the size variable
    size = len(digit)
    
    # We Create a while loop that creates the list like that [1,2,4,8,16,32,....]
    while size>c:
        a = a+a
        b.append(a)
        c = c+1
    
    # Reverse that List
    b = b[::-1]
    
    # Iterate the index of b variable for each number inside the b variable
    for d in b:
        index = b.index(d)
    
        # Place iterating index one by on digit variable, Then filter that indexes have 1 in that list.
        if digit[index] == 1:
            # Store all filtered values in the e variable
            e.append(d)
    
    # Do SUM of all numbers in the e variable 
    number = sum(e)
    # Print that Number
    print("Binary to Decimal number is ", number)
    
    




    I Hope, Your all queries were clear after reading this Binary to decimal in the python project post. Now, If you have any other queries about Binary to decimal in the python project, You can comment to us so we will try to clear your all queries about Binary to decimal in the python project.

    Post a Comment

    0 Comments