# cpsc111-w19-SampleQs.pdf - CPSC 111 Sample Final Exam Qs/As...

• 9
• 50% (2) 1 out of 2 people found this document helpful

This preview shows page 1 - 4 out of 9 pages.

The preview shows page 2 - 4 out of 9 pages.
1CPSC 111 Sample Final Exam Qs/AsExam Format:Final Exam will have around 30-35 Multiple Choice Qs (~50 pts]Show the expected output: ~10 ptsSHORT ANSWERS QUESTIONS (~10 pts)Programming Questions (~ 20 pts)Essay Qs (~10 pts):====================================================================THESE ARE NOT FINAL EXAM QUESTIONS TYPE. THESE ARE QUESTIONS TO HELPYOU PRACTICE ONLY.Practice with lists, strings, files: How to process them? How to slice them?Break, Continue,Conditional expression, try, except, recursion, decisions, aliasing,format operatoretc…Questions1. Complete the function below according to its specificationdef Question(s):""" Returns True if the characters at the start and end of s are different and occur nowhere else in sPreCondition: s is a string with length greater than or equal to 3."""Answer:def Question(s):""" Returns True if the characters at the start and end of s are different and occur nowhereelse in sPreCondition: s is a string with length greater than or equal to 3."""return s[0] != s[-1] and s.count(s[0]) == 1 and s.count(s[-1]) == 1word = input("Enter a string: ")print(Question(word))
Multiple Choice QuestionsFor the questions (1, 2, 3, and 4) below, use the following partial code shown in Figure 0:###############Figure 0###############A = 0B = 0C = 0D = 0while (A < 6:)D = D + 1if (D%3 == 0:)B = B + 1elif (D%3 == 1:)C = C + 1A = A + 2print( A ) # Line 1print( B ) # Line 2print( C ) # Line 3print( D ) # Line 41. Which of the following statements about the Python code labeled "Line 1"in Figure 0 iscorrect?(e)
2. Which of the following statements about the Python code labeled "Line 2"in Figure 0 iscorrect?(b)
2
3C) It will display 2 when the program is executed.D) It will display 3 when the program is executed.E) None of the above.

Course Hero member to access this document

Course Hero member to access this document

End of preview. Want to read all 9 pages?