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...
-
An experimenter is studying the effects of temperature, pressure, and type of catalyst on yield from a certain chemical reaction. Three different temperatures, four different pressures, and five...
-
You are given a solution containing a pair of enantiomers (A and B). Careful measurements show that the solution contains 98% A and 2% B. What is the ee of this solution?
-
8 What are two advantages and two disadvantages of the advertising posttests described in the chapter?
-
Equipment was purchased at the beginning of 2009 for $100,000 with an estimated product life of 300,000 units. The estimated salvage value was $4,000. During 2009, 2010, and 2011, the equipment...
-
A speculator buys a call option for $3, with an exercise price of $50. The stock is currently priced at $49, and rises to $55 on the expiration date. The speculator will exercise the option on the...
-
Smoothie Plc, a fruit juice manufacturer, has determined the following standard cost details for the three ingredients that are blended together to make their tropical fruit drink: Standard cost per...
-
Design a Qualitative Survey Essay Select a topic of interest in the field of psychology. Then, design a qualitative survey that includes five but no more than ten questions that would collect data on...
-
The probability that a printing press will print a book with no errors is 78%. The company is about to process an order of 30 books. Round decimals to 3 places or percentages to 1 decimal place. 9....
-
alculate Product Costs, using JOB COSTING SYSTEM. Please SHOW CALCULATION. Dream Chocolate Company: Choosing a Costing System TABLE 1 Typical Prices and Costs of Chocolate 641 1.25 oz. Bar 3.0 oz....
-
1.A woman eats 65g of protein per day. She weighs 156 lbs. How much protein is she getting per kg of body weight? Explain briefly both question 2.152 lbs = ________________kg. [2.2 lbs = 1 kg] explain
-
The concrete slab shown in Figure is 7m x 5m. The slab is not supported along one of the 7m long edges (free edge). The other three edges are supported and continuous over the supports, and therefore...
-
1. If possible, find 4-B -[{3}][{3}] A=
-
what revenue category(IRS needs to be added to the master chart of accounts to reflect the new economy (how buisness is conducted) and new technologies? what expense category needs to be added to...
-
What are conversion costs? What are prime costs?
-
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....
-
Endofperiod adjustments LO5 A physical count of inventories at 31 December 2020 revealed that Katoomba Pty Ltd had inventories on hand at that date with a cost of $441 000. Katoomba Pty Ltd uses...
-
Assignment of cost (periodic and perpetual methods) LO4, 5, 6 Darwin Ltds inventories transactions for April 2021 are shown below. Purchases Cost of sales Balance Date No. units Unit cost Total...
-
Recording inventories transactions LO3, 4 William Ltd began business on 1 March 2021. William Ltd balances the books at monthend and uses the periodic method. William Ltds transactions for March...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App