代写辅导接单-COMP10001 Foundations of Computing

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

COMP10001 Foundations of Computing

Semester 2, 2026

Tutorial Questions: Week 4

— VERSION: 1659, DATE: AUGUST 14, 2026 —

Exercises

What is shown on screen after you execute the program below? What is the value of res, res_p, res_r, and res_pr?

def ave(a, b):

result = (a + b) / 2

def ave_p(a, b):

result = (a + b) / 2

print("p", result)

def ave_r(a, b):

result = (a + b) / 2

return result

def ave_pr(a, b):

result = (a + b) / 2

print("pr", result)

return result

res = ave(1, 2)

res_p = ave_p(1, 2)

res_r = ave_r(1, 2)

res_pr = ave_pr(1, 2)

What’s wrong with this code? How can you fix it?

def calc(n1, n2):

answer = n1 + (n1 * n2)

print(answer)

num = int(input("Enter the second number: "))

result = calc(2, num)

print("The result is:", result)

Evaluate the following method calls given the assignment s = "Computing is FUN!" Think about the input and output of each method. You’re not expected to know all methods for all types: if you haven’t seen some of these before, your best guess based on the name will probably be right!

(a) s.isupper() (b) s.upper() (c) s.endswith("FUN!") (d) s.count('i') (e) s.strip('!') (f) s.replace('i', '!') (g) s.split() (h) s.isdigit()

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: Fudaojun0228