cpsc111-w19-SampleQs.pdf - CPSC 111 Sample Final Exam...

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

1 CPSC 111 Sample Final Exam Qs/As Exam Format: Final Exam will have around 30-35 Multiple Choice Qs (~50 pts] Show the expected output: ~10 pts SHORT ANSWERS QUESTIONS (~10 pts) Programming Questions (~ 20 pts) Essay Qs (~10 pts) :==================================================================== THESE ARE NOT FINAL EXAM QUESTIONS TYPE. THESE ARE QUESTIONS TO HELP YOU 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 operator etc… Questions 1. Complete the function below according to its specification def Question(s): """ Returns True if the characters at the start and end of s are different and occur nowhere else in s PreCondition: 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 nowhere else in s PreCondition: 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]) == 1 word = input("Enter a string: ") print(Question(word))
Multiple Choice Questions For the questions (1, 2, 3, and 4) below, use the following partial code shown in Figure 0: ############## # Figure 0 # ############## A = 0 B = 0 C = 0 D = 0 while (A < 6 :) D = D + 1 if (D%3 == 0 :) B = B + 1 elif (D%3 == 1 :) C = C + 1 A = A + 2 print( A ) # Line 1 print( B ) # Line 2 print( C ) # Line 3 print( D ) # Line 4 1. Which of the following statements about the Python code labeled "Line 1 " in Figure 0 is correct ? (e)
2. Which of the following statements about the Python code labeled "Line 2 " in Figure 0 is correct ? (b)
2
3 C) It will display 2 when the program is executed . D) It will display 3 when the program is executed . E) None of the above .

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture