Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Python Expert

Computer Science Number Systems Project Assignment

In this assignment you will add on to the source code from the Number Systems Lab in file "numberSystes.py". In the lab we defined a function for converting a character digit to its numeric value and laid out code that would simulate the Positional Notation method of converting numbers from any base to decimal. We will add to this the functionality to perform the Long Division method of converting a decimal to another base.

First take the code that you wrote that simulates Positional Notation and put it in a new function named "toDecimal". It will need to accept a character number and an integer base as parameters, and will return an integer decimal value.

Then define a function that can convert a number value to a character digit. For right now we will just assume we have valid values, so a zero through nine will convert to "0" through "9", and then a ten through fifteen will convert to "A" through "F".

Now create a function that simulates the long division method of converting a decimal to another base. It will need to receive an integer decimal value, and an integer base to convert it to, and will need to return a string value representing the converted value.

Remember that the long division method takes a decimal and divides it by the base to convert to. Each remainder of the division is the next digit in the result reading right to left. Each quotient from the division is used as the next dividend, until the quotient is zero.

A run of the program should prompt the user to enter a number, the base of the number, and the base to convert to the number to, and then print the results of converting the number to decimal, and then the decimal to the output base.

So a general process flow is:

  • Ask for number to convert
  • Ask for base of number
  • Ask for base to convert to
  • Set decimal to return of "toDecimal" passing the number-in and base-in
  • Print message number-in base base-in is decimal decimal-value
  • Set number-out to return of "fromDecimal" passing decimal and base-out
  • Print message decimal is number-out in base base-out

Outline of the fromDecimal function:

  • Define a string number-out and initialize it to an empty string, i.e. '' or "" (this will allow us to concatenate digits to it in a loop)
  • Set a quotient variable to the decimal passed in
  • Create while loop that checks for quotient great than zero
  • Set a remainder variable to quotient mod base-out
  • Set next-digit to return of valueToDigit passing in the remainder
  • Set a new-quotient variable to quotient integer-division base-out
  • Print this loop as: quotient / base-out = new-quotient , next-digit
  • Append next digit to front of number-out (e.g. sNumberOut = nextDigit + sNumberOut)
  • Set quotient to new-quotient
  • (Loop will continue till quotient is zero)
  • Return number-out

Attachment:- Assignment Files.rar

Python, Programming

  • Category:- Python
  • Reference No.:- M92698272
  • Price:- $60

Guranteed 36 Hours Delivery, In Price:- $60

Have any Question?


Related Questions in Python

Lab assignment -background - we have discussed in detail

Lab Assignment - Background - We have discussed, in detail, the function of Stacks and Queues and how they are specifically implemented in Python. To get a better understanding of the utility of these data structures, we ...

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

Question why is software configuration management

Question : Why is software configuration management considered an umbrella activity in software engineering? Please include examples and supporting discussion. The response must be typed, single spaced, must be in times ...

Question a software company sells a package that retails

Question : A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10 - 19 20% 20 - 49 30% 50 - 99 40% 100 or more 50% Write a program usi ...

Questionwhat is a python development frameworkgive 3

Question What is a python development framework? Give 3 examples python development framework used today. and explain which development framework is used in which industry.

Tasksdemonstrate data scraping of a social network of

Tasks Demonstrate data scraping of a social network of choice. Develop technical documentation, including the development of the code & detailing the results. Provide a report on the findings, that includes research into ...

Architecture and system integrationcase study queensland

Architecture and System Integration Case Study: Queensland Health - eHealth Investment Strategy After evaluating various platforms, Queensland Health finally decided to adopt a Service Oriented Architecture (SOA) for its ...

A software company sells a package that retails for 99

A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10 - 19 20% 20 - 49 30% 50 - 99 40% 100 or more 50% Write a program using python t ...

Question write a simple python program that takes use

Question: Write a simple python program that takes use inputs as non-zero digits and converts them into binary form. The response must be typed, single spaced, must be in times new roman font (size 12) and must follow th ...

Python programming assignment -you first need an abstract

Python Programming Assignment - You first need an abstract base class, called, Account which has the following attributes and methods: accountID: This attribute holds the ID assigned the account , if not provided set to ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As