CS代写 | CSCI.UA.0002 PRACTICE FINAL EXAM
本次美国代写主要为计算机科学的限时测试
CSCI.UA.0002 PRACTICE FINAL EXAM
1. (1 point)
What is the output of the following code?
x=”HOmE”
x[-2:]=”M”
print(x)
*a. TypeError: ‘str’ object does not support item assignment
b. HOME
c. HOmE
d. None of the above
2. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
word = “home”
newword = “”
for c in word:
if c == ‘e’ or c == ‘o’:
newword = “+”
else:
newword += c
print(newword)
3. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
word = “home”
newword = “”
for c in word:
if c == ‘e’ or c == ‘o’:
newword = “+”
else:
newword += c
print(newword.isalpha())
4. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
word = “home”
newword = “”
for c in word:
if c == ‘e’ or c == ‘o’:
newword += “+”
else:
newword += c
print(newword)
5. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
string = “i love chocolate cake”
print(string.capitalize())
6. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
string = “i love chocolate cake”
print(string.title())
7. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
string = “i love chocolate cake”
print(string.upper())
8. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
word=”HELLO”
new_word=””
for i in range(1,len(word),2):
new_word += str.lower(word[i])*3
print(new_word)
9. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
str1 = “Never&memorize$something@that%you#can&look$up.”
def changeString(str1):
new_word = “”
for i in str1:
if i.isalpha():
new_word += i
else:
new_word += ” ”
return new_word
print(changeString(str1))
10. (1 point)
What is the output of the following program? If an error occurs, write Error. ____
str1 = “hello”
new_str = “”
for i in range(len(str1)):
new_str += str(ord(str1[i]))
print(new_str)