# 编程代写｜FOUNDATIONS OF PROGRAMMING COMP 202-001/003 Final examination

Multiple choice questions (45 points)

i = 0

ct = 0

while i in range(0, 10, 2):

ct += i

i += 1

print(ct)

postal_code = “H0H-0H0”

postal_code.replace(“H0H”, “0H0H”)

print(postal_code.strip(“0H0”))

postal_code = “H0H-0H0”

other_code = “MU4-H4H”

print(postal_code.count(‘H’) + other_code.split(‘H’)[1].count(‘H’))

x, y = 5, 10

x = x * 5

y = x

z = 5

import copy

a = [1, 2, 3, 9001]

b = []

for x in a:

b = b + [x]

c = a

a = b[:]

b = copy.deepcopy(b)

import copy

a = [[1, 2], [11, 12], [21, 22]]

b = a[1]

c = b[:]

d = copy.deepcopy(a) + b

import copy

class WorldsBestClass:

def __init__(self):

self.name = “Hi!”

wc = WorldsBestClass()

oc = WorldsBestClass()

classes = [wc, oc]

classes += [oc]

c = copy.copy(classes)

d = {[3]: (3, 4), [5]: (5, 6)}

a = [3]

print(d.get(a, 0))

def swap_inputs(x, y):

return y, x

def apply(func, x, y):

return func(x, y)

print(apply(swap_inputs, swap_inputs, 5))

class Cat:

def __init__(self, name=‘Cheshire Cat’):

self.name = name

def __str__(self):

return self.name + ” says: Meow!”

print(Cat(‘Crookshanks’))