Midterm 1 Practice: CMPT 120
Midterm 1 Practice: CMPT 120
Midterm 1 Practice: CMPT 120
(a) Left
(b) None
(c) Up
(d) Down
(e) Error
3. 15 % 3 == 0
(a) True
(b) False
4. What are two kinds of programs that process high-level languages into low-level
languages?
(a) Interpreters and compilers
(b) interpreters and executors
(c) compliers and executors
(d) interpreters, compilers and executors
b=5 buzz
if b==4 and a==2:
print("fizz")
elif b>5:
print("fizzbuzz")
else:
print("buzz")
Ques 3. Coding
(a) [10 marks] Write a python code that receives a string from the user and then
outputs a new string from the original string where all occurrences of its first
character have been changed to '*' except for the first and third characters.
# get input
string = input("Enter a string: ")
# Receive a string
first_char = string[0] # Store the first character in a
variable
new_string = ""
def strConstruct():
new_string1 =""
new_string2 =""
strConstruct()