Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:35:02+00:00 2026-06-01T19:35:02+00:00

I am doing an exam paper for revision. It’s not a particular question I

  • 0

I am doing an exam paper for revision. It’s not a particular question I want help with, but I am unsure to why the program is outputting incorrectly when certain data is entered.

def Binary(Hex):
    Result = ''
    ErrorFound = False
    BinaryEquivalent = ''
    EmptyInput=""
    for ThisHexDigit in Hex:
        if ThisHexDigit in ['1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F']:
            if ThisHexDigit == '0': BinaryEquivalent = '0'
            elif ThisHexDigit == '1': BinaryEquivalent = '1'
            elif ThisHexDigit == '2': BinaryEquivalent = '2'
            elif ThisHexDigit == '3': BinaryEquivalent = '3'
            elif ThisHexDigit == '4': BinaryEquivalent = '4'
            elif ThisHexDigit == '5': BinaryEquivalent = '5'
            elif ThisHexDigit == '6': BinaryEquivalent = '6'
            elif ThisHexDigit == '7': BinaryEquivalent = '7'
            elif ThisHexDigit == '8': BinaryEquivalent = '8'
            elif ThisHexDigit == '9': BinaryEquivalent = '9'
            elif ThisHexDigit == 'A': BinaryEquivalent = '10'
            elif ThisHexDigit == 'B': BinaryEquivalent = '11'
            elif ThisHexDigit == 'C': BinaryEquivalent = '12'
            elif ThisHexDigit == 'D': BinaryEquivalent = '13'
            elif ThisHexDigit == 'E': BinaryEquivalent = '14'
            elif ThisHexDigit == 'F': BinaryEquivalent = '15'
            Result = Result + BinaryEquivalent
        elif ErrorFound == True:
            print('You have made a mistake')
        elif Hex==EmptyInput:
            print('Empty input, try again.')

    return Result

Yes, I know this is an over-complicated piece of code but it is in the exam paper so I have to use it. It came like that, except that all the BinaryEquivalent strings were BinaryEquivalent = '' instead of having numbers inside.

The problem is when I enter two characters when the program is displaying. For example, entering “BBB” will output 11, as will ‘BBBBBB’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:35:03+00:00Added an answer on June 1, 2026 at 7:35 pm

    You should put return statement out of the for cycle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst doing exam revision I am having trouble answering the following question from the
I am busy preparing for exams, just doing some old exam papers. The question
This is a question from a past exam paper. The code was given in
I am doing an online exam project. I want to submit a page after
I'm doing a online exam tool. I want to minimize the number of database
I have a piece of code from an exam paper that I'm doing for
Doing a some practice questions for exam tomorrow can't figure out this one What
I am doing online Exam Management, I have set a time duration for an
I'm doing some fill in the blanks from a sample exam for my class
Doing this works in IE7: <a href= target=_blank>Link</a> But in IE8 it open a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.