1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lozanna [386]
3 years ago
8

To reduce the number of used digital outputs of the microcontroller, the display board is connected to the main board through th

e integrated circuit of the decoder, which converts binary coded decimal (BCD) values to signals for the seven-segment display. So, to show any number on the display you need to set the required BCD code on the microcontroller's outputs. Write a program to convert an integer number represented as a string to a BCD code required for the display. In the BCD code, every decimal digit is encoded with its four-bit binary value. Encoding all digits of the decimal number and concatenating the resulting codes into one string you will get a resulting BCD code. A space is used to separate digits in the BCD code and make it more readable. For example, a number 173 will be encoded to BCD as 0001 0111 0011.
Computers and Technology
1 answer:
Luda [366]3 years ago
7 0

Answer:

The program in Python is as follows:

BCD = ["0001","0010","0011","0100","0101","0110","0111"]

num = input("Decimal: ")

BCDValue = ""

valid = True

for i in range(len(num)):

   if num[i].isdigit():

       if(int(num[i])>= 0 and int(num[i])<8):

           BCDValue += BCD[i]+" "

       else:

           valid = False

           break;

   else:

       valid = False

       break;

if(valid):

   print(BCDValue)

else:

   print("Invalid")

Explanation:

This initializes the BCD corresponding value of the decimal number to a list

BCD = ["0001","0010","0011","0100","0101","0110","0111"]

This gets input for a decimal number

num = input("Decimal: ")

This initializes the required output (i.e. BCD value)  to an empty string

BCDValue = ""

This initializes valid input to True (Boolean)

valid = True

This iterates through the input string

for i in range(len(num)):

This checks if each character of the string is a number

   if num[i].isdigit():

If yes, it checks if the number ranges from 0 to 7 (inclusive)

       if(int(num[i])>= 0 and int(num[i])<8):

If yes, the corresponding BCD value is calculated

           BCDValue += BCD[i]+" "

       else:

If otherwise, then the input string is invalid and the loop is exited

<em>            valid = False</em>

<em>            break;</em>

If otherwise, then the input string is invalid and the loop is exited

<em>    else:</em>

<em>        valid = False</em>

<em>        break;</em>

If valid is True, then the BCD value is printed

<em>if(valid):</em>

<em>    print(BCDValue)</em>

If otherwise, it prints Invalid

<em>else:</em>

<em>    print("Invalid")</em>

You might be interested in
27. List four advantages of Computer Aided Design over traditional hand
tatyana61 [14]

Decrease in error CAD software makes use of some of the best tools, the percentage of error that occurred because of manual designing is significantly reduced.

Decrease in effort when it comes to the amount of effort that was needed for the sake of designing the different models, it has been reduced significantly because the software automates most of the task.

Saves time when you are using the computer aided design software, it will save your time and you can make better and more efficient designs in shorter time duration.

Easy to edit when you are making designs, you may find the need to make alterations. When you are using computer aided design software, it will be much easier to make any changes because you can fix the errors and modify the drawings easily.

8 0
3 years ago
In report design view, you can use commands on the align button of the _____ tab.​
gogolik [260]
I'd say the Arrange tab

Sizing and moving fields in design view can sometimes be time consuming. Be that as it may, we can always use the tab order dialog box to perform this operation. To do so, we select the labels and fields in question, proceed to the Arrange tab, sizing and ordering group and then click on the Align button.


5 0
3 years ago
The security manager assigned a new security administrator the task of implementing secure protocols on all wireless access poin
Marysya12 [62]

Answer:

Good choice, as its one of the most secure wireless communications encryption methods, even though WPA2 would be the best

Explanation:

8 0
3 years ago
Hot components or sharp edges of computer is an example of what hazard​
Alexxandr [17]

Answer:

hot components or sharp edges of computer is an example of a mechanical hazard

6 0
3 years ago
. Which of the following is NOT a
joja [24]

Answer:

solution

Explanation:

The correct option is - solution

Reason -

To solve a problem,

Firstly we give input , then system will process that input which then gives output.

Solution is not a part of the process.

So, Solution is not a significant part of a simple problem.

7 0
2 years ago
Other questions:
  • Using the _______ list, you can select the number of photos that will appear on each slide.
    14·1 answer
  • Enhancing and optimizing customer retention and loyalty is a major business strategy.
    15·1 answer
  • A user saves a password on a website the user logs into from a desktop. Under which circumstances will the password be saved on
    14·1 answer
  • The most common solution to supply chain uncertainties is to build inventories or __________ as insurance.
    6·1 answer
  • What are some of the advantages of using the F measure (weighted harmonic mean) over using the Precision &amp; Recall when evalu
    15·1 answer
  • What function returns a line and moves the file pointer to the next line?
    9·1 answer
  • (1)similarities between backspace key and delete key. (2) different between backspace key and delete key. (3) explain the term e
    10·1 answer
  • There are many reasons to convert to the decimal numbering system. Select the best answer. When checking numeric values in compu
    5·2 answers
  • Which of the following items can you locate in a document using the navigation pane? Choose the answer.
    10·1 answer
  • You have been elected to assist the school's yearbook committee and newspaper club in purchasing new computers. The current comp
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!