联系我们: 手动添加方式: 微信>添加朋友>企业微信联系人>13262280223 或者 QQ: 1483266981
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()
COMP10001 Foundations of Computing最先出现在KJESSAY历史案例。