留学生CS代写：Python assignment CMPT 120 代写案例

1.同学朋友推荐

2.谷歌搜索、找论坛

3.看网站的内容和案例

Step1：添加微信，提交需求

Step2：获取报价，支付定金

Step3：交付成果，完成付款

Step4：免费售后，获取高分

留学生CS代写常见问题解答

Q：你们能提供代码的运行效果吗？

A：我们会提供完整的代码或者代码运行的效果视频，如果有进一步的需要，我们还会提供辅导课程，远程帮忙调试。

Q：在订单进行过程中，我能更换导师吗？

A：是可以的，但需要提前沟通并告知更换的原因，共同沟通解决方法。

Q：我需要怎么跟进我的订单进程？

A：我们的教务和客服会全程跟进你的订单进程，确保按时完成任务。

Q：计算机作业会有售后吗？

A：我们会建立一个专属的独立服务群，可直接与程师们联系，交付程序后，一般是7天售后时间，期间免费调整代码。

Given the code below:
# Main Program
n1 = int(input("Enter your first positive integer: "))
n2 = int(input("Enter your second positive integer: "))
s = n1 + n2
lst1 = decimalToBinary(n1)
print("The binary representation of", n1, "is", lst1)
lst2 = decimalToBinary(n2)
print("The binary representation of", n2, "is", lst2)
print("The binary addition of", n1, "and", n2, "is", lst3)
n3 = binaryToDecimal(lst3)
print("Converting the binary to decimal gives", n3)
if s == n3:
print("Since", s, "==", n3, ", it seems we did good job.")
else:
print("Since", s, "!=", n3, ", something went wrong.")
print("----------------------")
n = int(input("Enter a positive integer: "))
lst = decimalToBinary(n)
print("The binary representation of", n, "is", lst)
result = algo(lst)
print(lst, "became palindrome: ", result[0], "after ", result[1], "iterations")
define the four functions decimalToBinary, binaryAddition, binaryToDecimal and algo. The description of
each function is as follows:
o def decimalToBinary(n):
• This function takes a positive integer n > 0 as an argument and returns a List of integers (The
list elements must be integer type) where each element of the list is a binary digit, 0 or 1
obtained by the conversion of the integer argument n to binary.
You are not allowed to use the built-in function bin().
For example,
decimalToBinary(3) → [1, 1]
decimalToBinary(123) → [1, 1, 1, 1, 0, 1, 1]
decimalToBinary(2312) → [1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]
• This function takes two list arguments lst1 and lst2 representing two binary numbers and
returns a list of integers whose elements are obtained by the addition of the two binary
• How to add two binary numbers? Binary addition is like decimal addition, except that it carries
on a value of 2 instead of a value of 10.
0 + 0 = 0
1 + 0 = 1
0 + 1 = 1
1 + 1 = 10 (this is 0 carry 1)
1 + 1 + 1 = 11 (this is 1 carry 1)
To add two binary numbers, we simply add together the corresponding digits in each binary
number from right to left and if the sum is greater than what fits in a single digit, we carry a 1
into the next column.
For example,
1 1 1 1 1 ← carries
1 1 0 1 0 1
+ 1 1 1 0 1
1 0 1 0 0 1 0
We start by the first column from the right:
1) First column: 1 + 1 = 0 (with carry 1)
2) Second column: 0 + 0 + 1 (carried) = 1 (no carry)
3) Third column: 1 + 1 + no carry = 0 (carry 1)
4) Fourth column: 0 + 1 + 1 (carried) = 0 (carry 1)
5) Fifth column: 1 + 1 + 1 (carried) = 1 (carry 1)
6) Sixth column: 1 + 1 (carried) = 0 (carry 1)
7) Seventh column: 1 (carried)
o def binaryToDecimal(lst):
• This function takes a list lst representing a binary number and converts it to decimal and
returns the decimal number.
For example,
binaryToDecimal([1,0]) → 2
binaryToDecimal([1,0,1,0,0]) → 20
binaryToDecimal([1,0,1,1,1,0,1,1,0,0,1,0]) → 2994
binaryToDecimal([1,1,1,1,1,0,1,1,1,0,1,1,0,0,0,0]) → 64432
o def algo(lst):
• Below is an algorithm that produces palindromic numbers for most binary numbers: Let n be a
binary number:
• [STEP 1] If the number is palindromic STOP. If not, go to step 2
• [STEP 2] Reverse the digits
• [STEP 3] Add the reverse to the original number (binary addition), the sum is your new
number, go to step 1
For example,
1011 → 11011
1. 1011 is NOT palindromic
2. 1011 reversed is 1101
3. 1011 + 1101 = 11000
4. 11000 is NOT palindromic
5. 11000 reversed is 00011
6. 11000 + 00011 = 11011 is palindromic after 2 iterations
• This function takes a list lst representing a binary number and returns a nested lists with two
elements:
▪ First element: the resulting palindromic binary number,
▪ Second element: number of iterations required to get to a palindromic number
by the procedure mentioned above. Throughout this procedure, if after 10 iterations the
number is still NOT palindromic your function must return [None, -1].
For example,
algo([1,0]) → [[1, 1], 1]
algo([1,0,1]) → [[1, 0, 1], 0]
algo([1,0,1,1]) → [[1, 1, 0, 1, 1], 2]
algo([1,0,1,0,0]) → [[1, 1, 0, 0, 0, 1, 1], 5]
algo([1,0,1,1,0]) → [None, -1]

Recent Case

盘点留学生常用5 种最佳笔记方法，哪一种适合您

SCI期刊论文的发表过程是一项复杂而细致的工作，涉

轻松掌握万能Essay模板，撰写一篇合格的英文论文

Python可谓是当下最火的编程语言，同时，Pyt