I need help with a homework problem for my Intro to Computer Science class. For
ID: 3553603 • Letter: I
Question
I need help with a homework problem for my Intro to Computer Science class.
For this particular problem I have to Convert a Decimal to Binary.
Given:
Write a function that wil handle the conversion of user input decimal integer into a binary number as a single string.
Find:
Create a single function that takes the input, does the calculation, and produces the output.
Add this function to the menu.
Method:
1) While the current number is not zero:
-Find the remainder of the current number by 2.
-Record the remainder in a list.
-Then, divide the current number by 2.
-Set the current number to this quotient
2) Reverse the remainder record if necessary
3) Turn the list into a string
4) Use necessary string manipulations to show the correct number
5) Print out the string to the screen
Notes:
The list, the string, the concetenation, the list method append, and the string method join are very useful for this function.
Important:
Pythin, being a friendly language, has built in conversions for binary and other numbers.
Do not use these functions in your program. By all means, use them to check your work, but they should not be part of your final program code. The manipulation of the mathematics using a loop is required.
Comments:
For the problem given, include a section that describes what the problem does. These comments should include a short description of any:
-input
-output
-branching
-exception handling
Comments are required. Please make them legible and understanable.
Input Handling:
All inputs of this program must be checked. Either forgiveness (exception handling) or permission (input testing) must be in place for this program.
Example:
Please enter a decimal integer: 55
Binary: 110111
This is exactly what the assignment entails.If there are any questions, please let me know. This course is a struggle for me since it is my very first programming class. The problem has to be done in Python language. Please follow instructions carefully and accurately. I will allow a good amount of time and points.
Thank you for your help.
Explanation / Answer
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.