e03 : Final Exam 7:30PM

num ready? description exam date
e03 true Final Exam 7:30PM Wed 12/11 07:30PM

Exam logistics

Th Final Exam is on Wednesday, 12/11 in the regular lecture classroom but it starts at 7:30PM.


Guidelines last updated: Sunday, Dec 8, 2019


Book Chapters:

including whatever was addressed on the homework and in the labs.


Practice Problems

Look over the clicker questions on the slides, Exam 1 and Exam 2, and homework problems to make sure you know and understand those concepts not just the answers to those specific questions.

Below are some practice problems – solve them on paper first, before trying them out in IDLE.

import pytest

def test_perimRect_1():
   assert perimRect(4,5)==18

def test_perimRect_2():
   assert perimRect(7,3)==20

def test_perimRect_3():
   assert perimRect(2.1,4.3)==pytest.approx(12.8)

Notice that the third test case above uses pytest.approx(). Why is this required for this test case, but not for the first two?

A. aab+ aab+ abd + s
B. s=aabaababdc, s[-1]= s
C. aabaababdsabc- abc
D. aab*2+ abds

A. multiply(123,2) B. multiply(“123”,2) C. multiply(“123”, “2”) D. multiply([1,2,3],2)


* Find the line below that has syntax error:

```python
1          def hasZero(num):
2                tostr=str(num)
3                for i in range(len(tostr)):
4                     if(tostr(i)= “0”):
5                         return True
6                return false

Answer:

20 // 3 = 6
...
T and T → 

T and F → 

F and F → 

T or T → 

T or F → 

F or F → 
    def fileIO():
    infile= open("file.txt", "read")
    outfile = open("out.txt","read")
    x= infile.read()
    for i in x:
        if i = '\n':
        continue
        outfile.write(i)
    y = outfile.read()
    for j in y:
        print(j)
    print("Done")

It is helpful to design a pseudocode first, before trying to write down the code.

students = ["Joyce", "Brain","Muhammad","George","Charlotte"]
courses = [("CS40", 5), ("Phys1", 4), ("Eng101", 3),("ARTHI6A", 4), ("Psych1", 4)]
total_units = [ 21, 16, 15, 18, 13]

What would be the result of entering the following at the Python interactive shell prompt? (Be very precise. Note that True is not the same in Python as true; upper vs. lower case matters. You will not get full credit for answers that are not precisely correct. And note that "UCSB" and ["UCSB"] are not the same in Python—one is a string, and the other is a list of length one containing a single string.)


len(courses)
Joyce in students
len(courses[0])
CS in course[0][0]

max(total_units)
Phys1 in courses
Eng101 in courses[2]
4 in courses[1]

What would be the result of entering the following at the Python interactive shell prompt? You should omit the <class '___'> part and only write down the ___ part.


type(mixture)
type(4*mixture[1])
type(mixture[-1])


type(mixture[3])
type(3.14)
type(mixture[1][1])

from collections import namedtuple
Student = namedtuple('Student', 'name perm major gpa')

s1 = Student("Nitya", 123443,"CS", 3.8)
s2 = Student("Young", 8932737, "CE", 3.6)
studentsList = [s1, s2]