# Python Assistance In the document MCS 260 Intro to Computer Science Spring 2022 Project 1 Due in Gradescope by Friday, February 11 by 11:59pm RESOURCES A

Click here to Order a Custom answer to this Question from our writers. It’s fast and plagiarism-free.

In the document

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-<lastname>-<firstname>.py
to Gradescope where <lastname> and <firstname> are replaced with your last and first name,
respectively.

The first lines of your file should include the following:

#<firstname> <lastname>

#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 se-
quence 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.

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

Place your order now for a similar assignment and have exceptional work written by one of our experts, guaranteeing you an A result.

#### Need an Essay Written?

This sample is available to anyone. If you want a unique paper order it from one of our professional writers.

Latest Questions

See More »

See More »

See More »

See More »

See More »

See More »