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
hodyreva [135]
3 years ago
8

Write a Python program that translates a binary number of n bits to a decimal number. Your program should first ask the user the

length of the binary number (how many bits). Using that information, ask the user to provide each bit from lowest to highest. Once the user has entered all the bit values for the binary number, report back the decimal value. Hint: You should use the mechanism to convert binary to decimal in earlier lectures. Note: Your program should not use any functions or methods from any library.

Computers and Technology
1 answer:
KonstantinChe [14]3 years ago
3 0

Answer:

Follows are the code to this question:

n= int(input("please enter number of bits, which want to convert for binary to decimal numbers: "))

p= 1#defining variable p for calculate power

d= 0#defining variable d for calculate decimal value

for i in range(n):#defining for loop for input bits value

   b= int(input("Enter the bit value from lowest to highest: "))#input value in b

   if b==1:#defining if block that check input is 1 value

       d=d+p#calculating decimal value

   p=p* 2#calculating power

print("The converted decimal number is:",d)#print value

Output:

please find the attached file.

Explanation:

In the above-given code, n variable is defined, which takes the number of bits value which you want to convert into a decimal value.

In the next step, "d and p" variable is defined that calculates the power and decimal number and store its value respectively, in this step, a for loop is used that uses the "b" variable for inputs bits value into lowest to the highest form, and use the if block.

In this block, it checks if the input value is one then it calculates its power and store its value into the "d" variable and use the print method to print its value.  

You might be interested in
The______for our newest game keeps changing as we develop our concept and refine our goals.
antiseptic1488 [7]
I think d is the best here
6 0
3 years ago
Read 2 more answers
An advertisement for new headphones lists the cool colors available, the great sound quality, and the fabulous reviews but fails
Mama L [17]

d transfer

ive seen the ad

7 0
3 years ago
1. Bluetooth
Elza [17]

Complete Question:

1. A wireless technology standard for exchanging data over short distances

2. A particular brand of mobile phone/PDA

3. A network that operates over a limited distance, usually for one or a few users

1. Bluetooth

2. PAN

3. Blackberry

Answer:

1. Bluetooth 2. Blackberry . 3. PAN

Explanation:

1. Bluetooth is a wireless technology standard, used in order to exchange data between mobile devices, like smartphones, tablets, headsets, wearables, over short distances in a one-to-one fashion (which means that it is not possible to build a network based in Bluetooth).

2. Blackberry is a brand of mobile phones/PDAs, very popular a decade ago, because it was the first one to allow mobile users to access e-mails and messages from anywhere, at any time.

3. PAN (Personal Area Network) is an ad-hoc network that it is only available for data exchange at a very short distance, within the reach of a person, i.e. a few meters as a maximum.

It is thought to allow someone to interact with his nearest environment (laptop, tablet, PDA) and it can be wireless (like Bluetooth) or wired (via USB cables).

4 0
3 years ago
Leah and Santana have been requested to print a daily report of scheduled activities. Their supervisor needs to know if each par
Katyanochek1 [597]

Answer:

Boolean

Explanation:

Boolean is one of the primitive data types that will only hold either true or false value. This data type is commonly used in a variable that will track a status with only two possible outcomes.

For example, the<em> ParticipantPD</em> field is to track the payment status (paid or unpaid) of a participant. So, declare the<em> ParticipantPD</em> field as boolean data type will meet its purpose.

               boolean ParticipantPD = true;

               or

               boolean ParticipantPD = false;

8 0
2 years ago
My mom works from home selling her craft work online to people all over the world. She can do this from home because we have acc
postnew [5]
The computer and a device
7 0
3 years ago
Read 2 more answers
Other questions:
  • Please helpp!! I need it quickly!
    6·1 answer
  • HELP 10 POINTS AND BRAINLIEST FOR BEST ANSWER! EASY I PROMISE! HELPFUL ANSWERS ONLY PLEASE HURRY!
    14·2 answers
  • if your instructors teaching style is very different from your learning preference your best choice is to one work on your weake
    10·1 answer
  • A user is implementing security on a small office network. Which two actions would provide the minimum security requirements for
    10·1 answer
  • Which of the following software maintenance steps erases gaps caused by deleting files from the hard drive?
    10·1 answer
  • Define the following term. data, database, DBMS, database system, data- base catalog, program-data independence, user wen', DBA,
    12·1 answer
  • The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sumof the previous two, for example: 0, 1
    11·1 answer
  • What are the different types of application architecture
    5·1 answer
  • Create a two functions: first called grocery_cost(food), where food can be one item or a list of items from the stock and price
    7·1 answer
  • Use the drop-down menus to complete each statement. Two main versions of Outlook are the desktop app and the app. The has limite
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!