Posted: February 10th, 2022

Python Assistance

MCS 260 Intro to Computer Science Spring 2022
Project 1
Due in Gradescope by Friday, February 11 by 11:59pm
RESOURCES ALLOWED: This project is to be completed individually. The only resources you
may use when completing the project are
ˆ Material posted on the course Blackboard page
ˆ The course textbook and “further resources” listed in the Syllabus
If you are unsure about whether a resource is allowed, then please ask your instructor. You should
also consult the course syllabus for a further explanation of academic honesty.
WHAT TO SUBMIT: You will submit a single Python file project1-.py
to Gradescope where and are replaced with your last and first name,
respectively.
The first lines of your file should include the following:
#
#MCS 260 Spring 2022 Project 1
#I hereby attest that I have adhered to the rules for projects as well as UIC’s
Academic Integrity standards while completing this project.
The rest of your file should perform the actions described below.
ACTIONS: 1. Define the SplitBinary function
Here we define a function SplitBinary which takes as input a single positive integer input n.
The function then calculates a positive integer output as follows:
(a) Convert n to binary form, call it B. You may use the bin( ) function.
(b) Split B into two “halves”, call them F and S, where if the length of B is odd, then include
the extra digit in the first half. For example, if B = 101110, then the first half is F = 101
and the second half is S = 110. As another example, if B = 1100111, then the first half
is F = 1100 and the second half is S = 111.
(c) Convert F and S to decimal form, add one to each decimal form, and then return the
product of these new values.
As a full example, consider n = 23.
(a) Converting n to binary form, we have B = 10111
(b) Then F = 101 and S = 11
(c) Converting them back to decimal form, we have the decimal values 5 and 3. Finally, we
return the product (5+1)*(3+1) = 24.
Therefore SplitBinary(23) = 24.
2. Define the SplitBinary sequence
We can use SplitBinary( ) to turn one integer into another. We can iterate this process
over and over, generating a sequence of positive integers. For example, if we start with
the positive integer 15, then SplitBinary(15) = 16. Then SplitBinary(16) = 5, and
SplitBinary(5) = 6, and so on. This creates the sequence 15, 16, 5, 6, …. This sequence we will call the SplitBinary sequence starting with 15.
3. The final step!
Your program should prompt the user for a positive integer input, call it n. Your program
should then compute the terms of the Split Binary sequence starting with n and print them, one
at a time, on a new line. If your program ever prints a number that has already been
University of Illinois at Chicago Page 1
MCS 260 Intro to Computer Science Spring 2022
printed, it should print “Duplicate Found!” and not print any further elements
of the sequence.
Otherwise, if 20 terms of the sequence have been printed and there are no duplicates, then you
should print “20 iterations and no duplicates” and stop printing elements of the sequence.
4. ADD COMMENTS to clarify your choice of variables and to indicate what is happening at
different steps of the program. A good rule of thumb is one line of comments for every four
to five lines of code. Your comments will be checked to see that you understand how your
code is structured and what it is doing in the big picture. Code lacking in comments will be
penalized!
EXAMPLES Here are some examples of what your code should look like when run:
Enter a starting value: 15
15
16
5
6
4
3
4
Duplicate Found!
Enter a starting value: 154587
154587
143752
110433
42336
16102
12978
5202
1558
1127
288
19
20
6
4
3
4
Duplicate Found!
University of Illinois at Chicago Page 2
MCS 260 Intro to Computer Science Spring 2022
Enter a starting value: 54659876545479
54659876545479
2728625922160
629010402951
41544735232
24423982353
4821387034
2544531003
1175215636
863808525
297310636
119280231
68611432
28754808
6241669
4309872
1854505
76104
21754
20910
7708
20 iterations and no duplicates
University of Illinois at Chicago Page 3

Check Price Discount

More Assignment Samples: »

Order for this Paper or Similar Assignment Help

Fill a form in 3 easy steps - less than 5 mins.

Why choose us

You Want Quality and That’s What We Deliver

Top Essay Writers

We select the finest writers to join our team. They each have expertise in specific topic fields and background in academic writing.

Affordable Prices

We offer the lowest possible pricing while still providing the best writers. Our costs are fair and reasonable compared to other writing services.

100% Plagiarism-Free

You will never receive a product that contains any plagiarism. We scan every final draft before releasing it to be delivered to a customer.

How it works

When you decide to place an order with Study Pro Essay, here is what happens:

Complete the Order Form

You will complete our order form, filling in all of the fields and giving us as much detail as possible.

Assignment of Writer

We analyze your order and match it with a writer who has the unique qualifications to complete it, and he begins from scratch.

Order in Production and Delivered

You and your writer communicate directly during the process, and, once you receive the final draft, you either approve it or ask for revisions.

Giving us Feedback (and other options)

We want to know how your experience went. You can read other clients’ testimonials too. And among many options, you can choose a favorite writer.

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00