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.

Answers

Answer 1

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.  

Write A Python Program That Translates A Binary Number Of N Bits To A Decimal Number. Your Program Should

Related Questions

PLEASE HURRY!!!!

What will be the output of the following program? Assume the user responds with a 2.

answer = input ("How many books would you like? ")
priceBook = 3.20
intNumberBooks = float(answer)
moneyDue = intNumberBooks * priceBook
print ("You owe $", moneyDue)

A) You owe $ 6.40
B) An error occurs.
C) You owe $6.40
D) You owe $moneyDue

Answers

Answer:

A or C (depends on your programming language)

Explanation:

When someone replies to the input, "answer" is set to a string containing their reply -- in this case, 2. intNumberBooks is set to the floating-point value of "answer" (which is actually strange, since "int" implies an integer). So if the user responds with 2, intNumberBooks = 2. moneyDue then is set to the price times the number of books:

moneyDue = 2 * 3.20

So it will print moneyDue of $6.40. Whether the answer is A or C, though, depends on the programming language you're using -- I can't tell whether it will print a space after the $ or not, unfortunately.

The output of the given program if assuming the user responds with a 2 is You owe $6.40. The correct option is A.

What is the output?

Data input is required for programs. The program uses (processes) this data, and as a result, data (or information) is output. Any information that a program or other electronic device processes and sends out is considered its output. The output is anything that can be seen on the computer screen, such as the words you type on the keyboard.

When someone responds to an input, the floating-point value of "answer" in number books is set to a string expressing their response, in this case, 2.

Therefore, if the user replies with 2, the money owing is set to the price multiplied by the number of books:

Money Due = 2 x 3.20 = $6.40

Therefore, the correct option is A. You owe $ 6.40.

To learn more about output, refer to the below link:

https://brainly.com/question/28903099

#SPJ5

How many times would the following loop iterate?
Set k = 1
While k < 5
Display k
Set k = k + 1
End While

Answers

Answer:

The answer to this question is given below in the explanation section

Explanation:

The code is :

Set k = 1

While k < 5

Display k

Set k = k + 1

End While

this is a while loop, that will iterate 4 times and display the body of loop.  and at the fifth iteration, the loop condition does not meet the condition and the loop will get terminated.

What is the key difference between UDP and TCP protocols in TCP/IP reference model?

Answers

Answer:

TCP is a connection-oriented protocol, whereas UDP is a connectionless protocol. The speed for TCP is slower while the speed of UDP is faster.

Answer:

TCP is a connection oriented protocol.

UDP is a connectionless protocol.

Explanation:

PLEASE MARK ME AS BRAINLIEST

HAVE A NICE DAY :)

Which statement best describes which options should be used when printing envelopes?
A.)the address should always be filled out and the return address and postage will demand on the situation.
B.) The address and return address should always be filled out in the postage will depend on the situation.
C.) The return address should always be filled out in the address and postage will depend on the situation.
D.) The postage should always be selected in the return address and address will depend on the situation.

Answers

A or D I’m not too sure tbh but good luck

Answer:

B

Explanation:

You use utility software to_____. Select all that apply.

A play video games
B reformat a hard disk drive
C manage fonts on a computer
D write and edit documents

Answers

Utility software is system software designed to help analyze, configure, optimize or maintain a computer. Utility software usually focuses on how the computer infrastructure (including the computer hardware, operating system, software and data storage) operates.

You use utility software to:

Reformat a hard disk drive.Manage fonts on a computer.

What are utility software used for?

Utility software are known to be a kind of software that is often used to  configure and maintain any system.

Conclusively, Note that this software is made up of  small programs which can be used to  Reformat a hard disk drive and also to Manage fonts on a computer.

Learn more about  utility software from

https://brainly.com/question/20659068

Write a complete Java program that: Prompts an employee to enter the number of hours that they have worked in a given week and stores their response in a variable named hoursWork - Only whole hours are tallied, no partial hours Prompts the employee to enter their hourly wage in dollars and stores their response in a variable named payRate Computes the employee's weekly pay check under the following rules: All hours up to and including 40, are paid at exactly the employee's hourly wage - regular pay Any / All remaining hours, are paid at one and one half times the employee's hourly wage - overtime pay Displays to the screen a brief report including: The value of all of each of the user's inputs The amount of regular pay earned The amount of overtime pay earned You can find two separate sample runs of such a program in the unnamed box below the editor window.

Answers

Answer:

The solution is given in the explanation section

See comments for detailed explanation of each step

Explanation:

import java.util.Scanner;

public class QuestionOne{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       //Prompt User for input

       System.out.println("Enter Number of Hours worked this week");

       //Receive the value for number of hours

       int hoursWork = in.nextInt();

       //Prompt user for hourly wage rate

       System.out.println("Enter your hourly rate");

       double payRate = in.nextDouble();

       //compute pay

       double regularPay =0;

       //Calculate pay When there is no overtime

       if(hoursWork <= 40){

          regularPay = hoursWork*payRate;

           System.out.println("You worked for a total of "+ hoursWork+" at "+payRate

                   +" per hour, Your total pay is "+ regularPay);

       }

       // Calculate overtime pay

       //Obtain overtime by subtracting 40 from the total hours

       else{

           int extraHours = hoursWork-40;

           double overTimePay = extraHours*(1.5*payRate);

           regularPay = 40*payRate;

           System.out.println("You worked for "+hoursWork+" your regular pay is "+ regularPay+

                   " and your overtime pay is "+overTimePay);

       }

   }

}

CAR_SALE (Car_no, Date_sold, Agent_no, Commission_pct, Discount_amt)
Assume that a car may be sold by multiple agents, and hence {Car_no, Agent_no} is the primary key. Therefore, a single car sale may occupy multiple tuples.
Additional dependencies are:
Date_sold → Discount_amt and
Agent_no → Commission_pct
Based on the given primary key, is this relation in 1NF, 2NF, or 3NF? Why or
why not? How would you successively normalize it completely? Provide reasoning for each normalization.

Answers

1NF

In 1NF the relation should follow atomicity that means no repeating groups

In the relation there is no repeating groups

So

the relation is in 1NF

2NF

In 2NF, the relation should be in 1NF and each non prime

attribute must depend on primary key and No Partial dependency

Commission% is functional dependent on Salesperson# which is only part of the primary key.

So

relation is not in 2NF

3NF

In 3NF, the relation should be in 2NF and any NON prime attribute should not describe any non prime attribute.

Already we know relation is not in 2NF

there is a non prime attribute date_sold that describe another non prime attribute Discount_amt,

the relation is not in 3NF

Finally we come to. Know

the relation satisfies only 1NF

NORMALIZATION

The relation is not in 2NF

Decompose the relation CAR_SALE

CAR_SALES (Car#, Date_sold, Salesperson#, Discount_amt)

SALESCOMM (Salesperson#, Commission%)

CAR_SALES and SALESCOMM are in 2NF

In 3NF, the relation should be in 2NF and any NON prime

attribute should not describe any other non prime attribute

SALESCOMM relation is in 3NF

but CAR_SALES is not in 3NF the reason is that there is a

non prime attribute Date_sold that describes another non prime attribute Discount_amt.

So, decomposing the relation

CARSALEDATE (car#, salesperson#, Date_sold)

DATEDISS(Date_sold, discount_amt)

The relations CARSALEDATE

SALESCOMM

DATEDIS are in 3NF

Select the correct option that shows a function in F# that receives a list of integers and returns the average value all its elements as a float.
a. let averageList list = List.fold (fun acc elem -> acc + elem) 0 list / float list.Length
b. let averageList list = List.map (fun (acc,elem) -> acc + float elem) 0 list / list.Length
c. let averageList list = List.map (fun acc elem -> acc + elem) 0 list / list.Length
d. let averageList list = List.filter (fun (acc,elem) -> acc + elem) 0.0 list / float list.Length
e. let averageList list = List.fold (fun acc elem -> acc + float elem) 0.0 list / float list.Length

Answers

Answer: acc

Explanation:

Typing into a text _____
allows a user to place text on a slide without attaching the text to a visual object.

Answers

Answer:

box

Explanation:

Describe the big data life cycle

Answers

Answer:

Big data lifecycle consists of four phases: data collection, data storage, data analysis, and knowledge creation. Data collection phase consists of collecting data from different sources. In this phase, it is important to collect data from trusted data sources.

Explanation:

mark me as brainliest please

Answer:

Big data lifecycle consists of four phases: data collection, data storage, data analysis, and knowledge creation. Data collection phase consists of collecting data from different sources. In this phase, it is important to collect data from trusted data sources.

Explanation:

5.16 *zyLab: Hello IDE The goal of this problem is learn how to use Eclipse or IntelliJ. Submit the source code files (.java) below. Make sure your source files are encoded in UTF-8. Some strange compiler errors are due to the text encoding not being correct. Complete the following: In your chosen IDE, create a new project. You can name the project anything you like, we recommend "M5". Create a new class file, titled HelloIDE (which will create the file HelloIDE.java). Write a main method in this class that prompts a user for their name, and then replies with "Hello, ___!" filling in the blank with the typed in name, trimmed. Otherwise, if the string is empty, or just contains only whitespace, or if no input is given, output "Hello, stranger!". Example input/output for input "Mark":

Answers

Answer:

import java.util.Scanner;

public class HelloIDE

{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

   

 System.out.print("Enter your name: ");

 String name = input.nextLine();

 

 name = name.trim();

 

 if(name.equals(""))

     name = "stranger";

     

 System.out.println("Hello, " + name + "!");

}

}

Explanation:

import the Scanner class to be able to get input from the user

Create an object of the Scanner class called input

Ask the user to enter the name and set it to the name

Trim the name using trim() method, removes the whitespaces from the string

Check the name. If name is equal to "", set the name as stranger. This way if the name is empty, or just contains whitespaces or if name is not given, name will be set as stranger.

Print the name in required format

How can you get to the Excel Function Reference information? Check all that apply.

Answers

Answer:

Click the cell in which you want to enter the formula.

In the formula bar. , type = (equal sign).

Do one of the following, select the cell that contains the value you want or type its cell reference. ...

Press Enter.

Explanation:

Answer:

Help tab

F1

searching in the tell me bar

Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (currentPrice * 0.045) / 12.

Ex: If the input is 200000 210000, the output is:

This house is $200000. The change is $-10000 since last month.
The estimated monthly mortgage is $750.0.

Answers

Answer:

here is the answer

Explanation:

current_price = int(input("Enter the current price: "))

last_months_price = int(input("Enter the last month's price: "))

print("Current price is: " + str(current_price) + ", Last month's price was: " + str(last_months_price))

print("The change since last month is: " + str(current_price - last_months_price))

print("The estimated monthly mortgage is: " + str(current_price * 0.051))

Get the inputs for the current price and last month's price

Print the prices

Calculate and print the change, current_price - last_months_price, since last month

Calculate, using given formula, and print the estimated monthly mortgage

Enter("Enter the current price: ") current price = int, enter("Enter the last month's price: ") last months price = int.

What is Program?

The price last month was: " + str(last months price) and the current price is: " + str(current price) + ".

print("The difference from the previous month is: " + str(current price - last months price)). print("The approximate mortgage payment is: " + str(current price * 0.051))

Obtain the inputs for the price today and the price last month.

Therefore, Enter("Enter the current price: ") current price = int, enter("Enter the last month's price: ") last months price = int.

To learn more about program, refer to the link:

https://brainly.com/question/3224396

#SPJ2

What is the significance of backing up data on a computer?

Backing up data allows you to browse the Internet more quickly.
Your computer will never become infected with a virus.
A copy of your work can be saved in case the computer crashes.
The web cache will be cleared regularly.

Answers

Answer:

the answer is c

Explanation:

i got it right

Answer:

c

Explanation:

edg2020

BRAINLIEST AND 50 POINTS PLEASE AND FAST FAST FAST FAST FAST!!!!!!
What are three things that the use of color on a website do?

Answers

Answer: Colors can attract the attention of others, create the environment for a website, and it has an impact on how people feel about that website. When you dig into the psychology part of it, there is a variety of different things you can do with color on a website.

In order to share resources, Windows devices must be part of

Answers

In order to share resources, Windows devices must be part of a workgroup called WORKGROUP.

Are resources shared in a network?

In computing, we often shared resource, or network. This is known to be when a computer resource is said to be made available to people from one host to other hosts and this is usually done on a computer network.

Note that Advanced Sharing is said to be a way of sharing resources in Windows as it helps one to have a detailed customization of the way one what to do the sharing.

Learn more about  Windows devices from

https://brainly.com/question/26420125

Find 10 real world challenges and their corresponding solutions

Answers

Answer:

Climate Change - Save energy at home, Walk, cycle or take public transport

Health Care - Focus on Patient Engagement.

Violence - Take all violence and abuse seriously.

Homelessness - A Coordinated Approach. To end homelessness, a community-wide coordinated approach to delivering services, housing, and programs is needed

Food Insecurity - Reduce Food Waste

Education Problem - Adoption of technology. Effective use of technological tools in teaching has many benefits.

Pollution- Reduce the number of trips you take in your car and reduce or eliminate fireplace and wood stove use.

Unemployment - Change in industrial technique.

Government Corruption - expose corrupt activities and risks that may otherwise remain hidden.

Malnourishment & Hunger - Food Donations, transitioning, and urban Farming

Explanation:

What are programs that organize, analyze, and graph numeric data such as budgets and financial reports.

Answers

Spreadsheets organize, analyze, and graph numeric data such as budgets and financial reports. They are widely used by nearly every profession. Microsoft Excel is the most widely used spreadsheet program.

Which mynav module serves as the source for sales and delivery content, assets, and internet and intellectual property across industries?

Answers

Accenture's myNav is the mynav module serves as the source for sales and delivery content, assets, and internet and intellectual property across industries.

What are myNav modules?

myNav is a tool that is used by companies so as to manage the human, technology and also some other dimensions of cloud services in business.

The Accenture's myNav is known to be the right tool for the above platform as it on that can help the firm and the people to choose end-to-end cloud solutions.

Learn more about  Accenture from

https://brainly.com/question/24918185

_______________involves engineers building up a 3D geometry piece by piece.

2D sketches turn into 3D features, with constraints and relations duly applied to fit the designer’s intent.

Answers

Answer:

Parametric design involves engineers building up a 3D geometry piece by piece. 2D sketches turn into 3D features, with constraints and relations duly applied to fit the designer's intent.

Explanation:

Hope this helps

Plzzzzzzz help good answers only and best answer gets brainly

Answers

Answer:

Desmos (colab w/h math antics) , Calendar, Quizlet (colab w/h google) , Quizizz (colab w/h quizlet) , Kahoot (colab w/h google) , or Google Translate

Last week, a disk containing CSM Tech Publishing’s current project manuscripts crashed. Fortunately, there was a backup, but all files that had been added or changed that day were lost. A new disk had to be purchased for overnight delivery, and the data had to be restored. Several days of work were lost. The owner of CSM Tech wants to know what can be done to prevent the loss of data and time if a disk crashes in the future. The server currently has two disks installed: one for the Windows boot and system volumes and one for manuscript files. The disk used for manuscript files is about one-third full. There’s enough money in the budget to purchase up to two new drives if needed. a. What solution do you recommend, and why?

Answers

Answer:

They should go for cloud based model

Explanation:

Cloud based model should be sort after because with such a model there can be a restoration of contents in just a little period of time. As for the usage, payments can be done. They would have highly packed response time, turn around time and also provide information security. At a go, there is flexibility in terms of storage and information retrieval. This may be more costly though but it would be helpful for data recovery without requiring physical data transmission

write a program that accepts three decimal numbers as input and outputs their sums?​

Answers

Answer:

The answer to this question is given below in the explanation section

Explanation:

The code is written in C++ language:

// Example program

#include <iostream>

#include <string>

using namespace std;

int main()

{

 double number [3];

 double addition=0;

 for (int i=0;i<3;i++)

 {

     cout<<"Enter decimal number at position " <<i+1< " ";

     cin>>number[i];

     addition= addition+ number[i];

           

     }

 cout<<"The addition is "<<addition;

}

Why is computer called diligent machine? ​

Answers

Computer is called diligent machine because it can perform the task repeatedly without loosing its speed and accuracy for a long time.

[tex]\huge\bold\green{Answer:-}[/tex]

Diligence: - It is a characteristic of computer. Computers can work for many hours continuously without taking any rest and without decreasing its speed, accuracy and efficiency. It is free from tiredness,lack of concentration, fatigue etc.2)Versatile: -Computer is a versatile machine which can do varieties of task such as simple calculation to a complex and logical operation. It is used in various fields for various purposes.

Computer are persistent and power to do work for hours without tiredness and fatigue with same level of accuracy. That is why Computers are called diligent.

ʜᴏᴘᴇ ɪᴛ ʜᴇʟᴘꜱ❤

Database policies should be created and implemented by all organizations, regardless of the ________ of the organization.

Answers

Database policies should be created and implemented by all organizations, regardless of the size of the organization.

What are database policies?

A database is a large collection of data that has been formatted to fit a certain standard. Database policies are law, enacted to protect usage of data by an individual, firms or governments.

The advantages of using a database would be that the information found there has been selected by experts in the field, while it also includes scholarly information that has been published or presented for review.

Hence, database policies should be created and implemented by all organizations, regardless of the size of the organization.

Learn more about database policies here: https://brainly.com/question/379106

Compare and contrast frame header to internet protocol header.

Answers

A Frame Header is known to have the source and the destination addresses of all the frame and the control bytes while the  IP header is known to be the header information at the start of an Internet Protocol packet.  

The IP packets is made up of a header that is used for addressing and routing.

What is IP header?

This type of header is known to have the source address and the destination address.  IP is known to be one that uses an Internet datagram that has all the information that are the same to the physical frame.

A frame is regarded as the unit of transmission that is found on a link layer protocol. It is made up of a link layer header that is known to be followed by a packet.

Learn more about  IP header from

https://brainly.com/question/4297610

Alice has an item x and Bob has a set of five distinct items y1, y2, y3, y4 and y5. Design a protocol through which Alice (but not Bob) finds out whether her x equals any of Bob's five items; Alice should not find out anything other than the answer ("Yes" or "No") to the above question, and Bob should not know that answer or any secret from Alice. Do not use a hash-based solution because even though the probability of a colission is small, Alice requires that no such colission can occur (but using encryption is fine, because in that case two distinct items that are encrypted with the same key will result in two different ciphertexts).

NOTE: THE SOLUTION FOR THIS SHOULD BE MATHEMATICALLY EXACT.

Answers

The protocol shows that the items of Alice = {x} and the items of Bob = {y1, y2, y3, y4, y5}

How to depict the protocol

The ways to design the protocol will be:

Alice will get Bob's public key.Alice will send a communication to Bob encrypted through Bob's community key.Bob's motivation has a clandestine key.Through the top-secret key, Bob will try to work out the communication.Bob will give a response called yes or no.Bob doesn't know what substances are with Alice.If Alice Alice gets any of the responses as yes then Alice's item is equivalent to any of Bob's five items.If Alice's items are not equal to Bob's items then Alice will get a response as no.

It should be noted that protocol is important for relaying datagrams across the network boundaries.

Learn more about protocol on:

https://brainly.com/question/17062016

okay this is a odd question but what is this symbol called?
< > what are these called lol

Answers

Answer: greater then or less than lol

Explanation: I learned it in elementary-

Explanation:

the one that "eats" the number means that one is greater.

greater than and less than.

hope this helps !

Whats is a better game?

Answers

Answer:

The first two are the best ones I see here, because I play them. Not sure how else to say that. Please make sure to also use brainly for school, though. Thanks!

A template is usually opened by
O clicking on a slide's thumbnail and choosing a template in the Design tab gallery.
O opening the Design tab and then right-clicking on a thumbnail in the gallery and selecting Apply to All Slides.
O clicking on New under the File tab and then selecting a thumbnail from the Templates gallery.
O opening the File tab and then right-clicking on Save As and selecting Apply to All Slides after picking a template.

Answers

The first answer choice

Answer:

A

Explanation:

Other Questions
Need help pls Need it Which of the following were the most common way that prior civilizations in the Americas influenced the Mayans, Inca and Aztecs?a.through direct conquest and ruleb.through religious beliefsc.through technologyd.through interaction and long-distance trade Scientists have found that mountain ranges from different continents show rocks that are similar in age and sequence. Based on these observations, what conclusions can be made. * What is the relationship between angles 1, 2, and 3? Explain how you could determine whether21312012and 79 have the same decimalequivalent. Use vocabulary words in your explanation. POINTS!! I NEED HELP WITH THIS, WILL GIVE BRAINLIEST TO BEST ANSWER What does agua mean help!! I need to know for my Spanish test Which Image is correctly labeled prokaryotic cell? A: Image 1. B: Image 2. C: Image 3. D: Image 4. was there an instance when you did a sort of inquiry or research describe your experience Which of the following happens to an object in uniform circular motion?A. its velocity changesb. its speed changesc. its centripetal acceleration changesd. the direction of its velocity stays the same which type of reproduction produces offspring with better characteristics ? you and your business partner are mailing advertising flyers to your customers. you address 6 flyers each minute and have already done 80. your partner addresses 4 flyers each minute and has already done 100. calculate when the two of you will have addressed equal numbers of flyers. Which equation is equivalent to 4x 14 + 2x = 70?Group of answer choices8X = 562X = 5620X = 706X = 84 are you a protesting student? How do the "laws of supply and demand" operate in a market economy? what is the environmental effect of 3NaCl Find the slope using these two coordinate points:(0, 15) and (4, 3)Your answer What is respiration? Scientists have found that mountain ranges from different continents show rocks that are similar in age and sequence. Based on these observations, what conclusions can be made. * solve the equation and graph the solution:24 + 6k < -6(-4-k)