Question 1. Create a program script to convert base-2 numbers to base-10. Test your program on...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 1. Create a program script to convert base-2 numbers to base-10. Test your program on the following: a) 1011001 b) 0.01011 c) 110.01001 A sample pseudocode to perform the conversion operation is given below: • Ask user to enter a base-2 number. Store the result in num. • Set result = 0. • Count no of digits in num. • Starting from first digit (least significant), for each digit = 1, set result = result + 2 ^ position, where position runs from 0 to no of digits-1. • Repeat until all digits are added. Note that you can modify your code so that when a point (.) is found in the entered string, resulting value has to be divided by 2 ^ (position of point counted from right). Question 1. Create a program script to convert base-2 numbers to base-10. Test your program on the following: a) 1011001 b) 0.01011 c) 110.01001 A sample pseudocode to perform the conversion operation is given below: • Ask user to enter a base-2 number. Store the result in num. • Set result = 0. • Count no of digits in num. • Starting from first digit (least significant), for each digit = 1, set result = result + 2 ^ position, where position runs from 0 to no of digits-1. • Repeat until all digits are added. Note that you can modify your code so that when a point (.) is found in the entered string, resulting value has to be divided by 2 ^ (position of point counted from right).
Expert Answer:
Answer rating: 100% (QA)
Python def binarytodecimalbinarystr result 0 haspoint False position 0 for digit ... View the full answer
Related Book For
Fundamental Accounting Principles Volume 1
ISBN: 9781259259807
15th Canadian Edition
Authors: Kermit Larson, Tilly Jensen, Heidi Dieckmann
Posted Date:
Students also viewed these programming questions
-
Is your course instructor a manager? Discuss in terms of planning, organizing, leading, and controlling. Also discuss using Mintzbergs managerial roles approach.
-
Is your course instructor a manager? Discuss in terms of managerial functions, managerial roles, and skills.
-
Course evaluation ratings for four college instructors are shown in the following table. Use = .05 and test for a significant difference among the rating for these instructors. What is your...
-
Learning by doing is an integral part of the course experience albeit online. The intent of this assignment is for you to demonstrate your ability to apply course content. Thus in the Marketing...
-
Although all nine of the competitive priorities discussed in this chapter are relevant to a companys success in the marketplace, explain why a company should not necessarily try to excel in all of...
-
Differentiate between a positive linear relationship and a negative linear relationship between variables.
-
What is a verified pleading?
-
Information about Indiana Industrial's utility cost for the last six months of 2010 follows. The highlow method will be used to develop a cost formula to predict 2011 utility charges, and the number...
-
Each year a local public high school allows the valedictorian of the senior class to deliver a speech at graduation. The school does not provide any guidelines beyond a 10 minute limit. This year,...
-
Use polygons and lines to create a graphics image that looks like a fireworks display. Write an application that extends JPanel and displays the fireworks. Save the file as JFireworksPanel.java.
-
Westnet organization in Boston Analysis of the Initiative or Problems- Applying the Three Lenses: answer to this question . Your analysis will be a rigorous exploration of your hypothesis,...
-
Discuss the differences between the characteristics of low- and high-value sales.
-
Which of the following would not be considered an advantage of using an internal control questionnaire in understanding and documenting the controls in an important accounting application?...
-
A survey of 250 members from an organized union of over 20,000 members. In Exercises 1120, determine whether the data set is a population or a sample. Explain your reasoning.
-
The accounts payable department receives the purchase order form to accomplish all of the following except. a. Compare invoice price to purchase order price. b. Ensure that the purchase had been...
-
Authorization of transactions in a computerized processing environment can take place in the form of: a. Computerized authorization in the form of user-approved blanket authoriza- tions. b....
-
Tobacco Cessation Education Video Estimated time: 20 minutes to prepare and record the 3-minute video. Using Studio within Canvas. After reviewing the assigned materials (readings and lectures),...
-
Audrey purchases a riding lawnmower using a 2-year, no-interest deferred payment plan at Lawn Depot for x dollars. There was a down payment of d dollars and a monthly payment of m dollars. Express...
-
Use the information given and the analysis completed in Exercise 2-5. Exercise 2-5 William Curtis is a personal finance expert and owns Much Money Consulting. This is his first month of operations...
-
Identify and explain the criteria that must be met before recording accounts receivable and revenue.
-
MY Auto bodys adjusted trial balance on December 31, 2017, appears in the work sheet as follows: Required 1. Prepare closing entries. 2. Prepare the post-closing trial balance at December 31, 2017....
-
If the resultant of forces acting on a body does not pass through the centre of mass, then the inertia force and inertia couple is replaced by (a) Equivalent inertia force (b) equivalent inertia...
-
What is inertia force?
-
A slider crank mechanism is loaded as shown in Fig. \(11.35 . A B=400 \mathrm{~mm}, B C=600 \mathrm{~mm}, A D=200\) \(\mathrm{mm}, C E=300 \mathrm{~mm}\). Calculate the input torque for the static...
Study smarter with the SolutionInn App