
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
![A student wants to design and implement a Python program to convert any 6-bit unsigned
binary number to its decimal equivalent. There are many ways of doing this, but here is their
initial top-level decomposition:
> Convert binary to decimal
>> Input a list of six 1s and Os corresponding to the binary number to be converted
>> Input a list of six column weightings consisting of powers of two
>> Create a new list that contains the decimal values of each binary digit of 1 in
the input list
>> Add up the decimal values in the new list and print result
a. In this part of the question you will consider only this section of the top-level algorithm:
>> Input a list of six 1s and Os corresponding to the binary number to be converted
>> Input a list of six column weightings consisting of powers of two
>> Create a new list that contains the decimal values of each binary digit of 1 in
the input list.
In order to test your code you should also add the step
>> print the new list
In order to test this part of your program, you will create a binary number based on your
Pl. [Your Pl is the long number that starts with a letter, followed by either seven digits or
6 digits and an X].
Perform the following steps with pen and paper - you should not write code for these
steps:
For each of the first 6 digits in your PI, create an input list of 1s and Os of length 6 as
follows:
If a digit in your Pl is even, append 0 to the input list, if it is odd, append 1 to the input
list.
For example, for the PI B0381720, the first six digits (in order) are even (0), odd (3),
even (8), odd (1), odd (7), even (2).
So your input list would be [0,1,0,1,1,0]
The list of conversion values for converting binary to decimal will always be [32, 16, 8, 4,
2, 11.](https://content.bartleby.com/qna-images/question/93f7a956-90c5-482f-8e23-e0ecfe3c1f58/ac3a2b27-f39e-4e7f-8757-9ea8fe332f9b/mwiilz_thumbnail.png)
Transcribed Image Text:A student wants to design and implement a Python program to convert any 6-bit unsigned
binary number to its decimal equivalent. There are many ways of doing this, but here is their
initial top-level decomposition:
> Convert binary to decimal
>> Input a list of six 1s and Os corresponding to the binary number to be converted
>> Input a list of six column weightings consisting of powers of two
>> Create a new list that contains the decimal values of each binary digit of 1 in
the input list
>> Add up the decimal values in the new list and print result
a. In this part of the question you will consider only this section of the top-level algorithm:
>> Input a list of six 1s and Os corresponding to the binary number to be converted
>> Input a list of six column weightings consisting of powers of two
>> Create a new list that contains the decimal values of each binary digit of 1 in
the input list.
In order to test your code you should also add the step
>> print the new list
In order to test this part of your program, you will create a binary number based on your
Pl. [Your Pl is the long number that starts with a letter, followed by either seven digits or
6 digits and an X].
Perform the following steps with pen and paper - you should not write code for these
steps:
For each of the first 6 digits in your PI, create an input list of 1s and Os of length 6 as
follows:
If a digit in your Pl is even, append 0 to the input list, if it is odd, append 1 to the input
list.
For example, for the PI B0381720, the first six digits (in order) are even (0), odd (3),
even (8), odd (1), odd (7), even (2).
So your input list would be [0,1,0,1,1,0]
The list of conversion values for converting binary to decimal will always be [32, 16, 8, 4,
2, 11.
![So the input list [0,1,0,1,1,0] would result in the output list [16, 4, 2].
i. Describe the type of the input and output data for this first task and describe the
allowable values for each.
ii. Specify one further test list in addition to the list you have created using your Pl
number. Make sure that you state the test input, the expected output and a brief
explanation of why you selected this test.
iii. Write an algorithm based on Pattern 2.3 Note that you will need to modify step 4ai.
iv. Implement your algorithm as Python code. Your code must match the steps of your
algorithm and you should use comments in the code to make it clear how the two
correspond. Marks will be lost if the program does not follow the algorithm. Copy
your Python code, as text, into your Solution document. Name your Python file
Q2a_OUCU.py, where 'OUCU' is your OU computer username, e.g. abc123. Then
include the code file in your TMA zip file.](https://content.bartleby.com/qna-images/question/93f7a956-90c5-482f-8e23-e0ecfe3c1f58/ac3a2b27-f39e-4e7f-8757-9ea8fe332f9b/nnrolj8_thumbnail.png)
Transcribed Image Text:So the input list [0,1,0,1,1,0] would result in the output list [16, 4, 2].
i. Describe the type of the input and output data for this first task and describe the
allowable values for each.
ii. Specify one further test list in addition to the list you have created using your Pl
number. Make sure that you state the test input, the expected output and a brief
explanation of why you selected this test.
iii. Write an algorithm based on Pattern 2.3 Note that you will need to modify step 4ai.
iv. Implement your algorithm as Python code. Your code must match the steps of your
algorithm and you should use comments in the code to make it clear how the two
correspond. Marks will be lost if the program does not follow the algorithm. Copy
your Python code, as text, into your Solution document. Name your Python file
Q2a_OUCU.py, where 'OUCU' is your OU computer username, e.g. abc123. Then
include the code file in your TMA zip file.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please help (in python) – Refer to questions attached in the images, and the starter code below (I cannot upload page 3 with example outputs for removeDuplicates(self)). Do not change the function names or given starter code in your script. You are not allowed to use any other data structures for the purposes of manipulating/sorting elements, nor may you use any modules from the Python to insert and remove elements from the list. You are not allowed to swap data from the nodes when adding the node to be sorted. Traversing the linked list and updating ‘next’ references are the only required and acceptable operations. You are not allowed to use any kind of built-in sorting method or import any other libraries. If you are unable to complete a function, use the pass statement to avoid syntax errors. Starter code - class Node:def __init__(self, value):self.value = value self.next = None def __str__(self):return "Node({})".format(self.value) __repr__ =…arrow_forwardModify the code to generate the Fibonacci sequence in the following ways, and complete each ofthe tasks using both the for- and while-loop.(a) Change the first two elements to 2 and 2.(b) Change the first two elements to 3 and 2.(c) Change the update rule from summing successive elements to taking differences of successiveelements. For example, the third element is defined as the second element minus the first element, andso on.(d) Change the update rule so that each element is defined as the sum of the three precedingelements. Set the third element as 1 in order to start the process.arrow_forwardPlease write a program that checks if the last data item entered appears earlier in the list. The input is a sequence of non-negative numbers, which is terminated by a user entering a -1. The code needs to output ONLY ONE of these 3 messages: Yes the last data item appears earlier, No the last data item appears earlier, No Data Provided The code is also not allowed to compare the last number with itself. Thanks!arrow_forward
- In your essay, you should talk about both the benefits and the drawbacks of skipping the skip list.arrow_forwardpythonarrow_forwardWrite one line of code ONLY.Print the sorted list, num from maximum to minimum, using the list given below: num = [5, 1, 9, 4, 3] Just make sure to precisely match the output format below.Write your code in the ANSWER area provided below (must include comments if using code is not covered in the course).Example Output[9, 5, 4, 3, 1]arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education