Are there any questions before I begin?
The final exam will be held on Thursday, May 21st from 3 to 6 PM.
The exam will be given in this room.
If for some reason you are not able to take the Final at the time it will be offered, you MUST send an email to me before the exam so we can make alternative arrangements.
The final will consist of questions taken from the Weekly Graded Quizzes, along with questions asking you to write short segments of Python code.
There is a link to the answers to the graded quizzes on the class web page.
60% of the points on this exam will consist of questions from the Graded Quizzes.
You do not need to study a Graded Quiz question if the topic is not mentioned in either the Midterm or Final review.
The remaining 40% will come from 4 questions that ask you to write some code.
To study for the code questions you should know
A good way to study for the code questions is to review the Class Exercises, homework solutions and Class Notes.
The today's class will be a review session.
You will only be responsible for the material in this review session, and the review for the Midterm, which you will find here.
Although the time alloted for the exam is 3 hours, I would expect that most of you would not need that much time.
The final is a closed book exam.
To prevent cheating, certain rules will be enforced during the exam.
At the end of each semester we offer you the opportunity to say what you think about this course.
What have I done right?
What have I done wrong?
What can I do better?
You are not asked for you name.
So the submissions are anonymous.
I will not see your responses until after I have submitted grades for this course.
We collect this feedback through Course Evaluations.
I will use what you say to make this course better.
To complete the course evaluation, use the following link .
After I finish speaking I will leave the class but stand outside the door.
I will ask all of you to fill out the Course Evaluation
A normal semester has 28 classes.
But this semester has 29.
I do not have materials for a 29th class.
Next Tuesday I will have Zoom Office Hours, from 9 AM to 5 PM, instead of a class.
The Zoom session will be conducted from my home in Somerville.
Not my office on the UMB campus.
Today I will review the material that we have covered since the midterm that you will have to know for the final.
class CLASS_NAME:
def __init__(self[, PARAMETER, ...]):
...
def METHOD_NAME(self[, PARAMETER, ...]):
...
return statement
OBJECT_VARIABLE = CLASS_NAME([PARAMETER, ...])
date = Date(date_string)
print(date.format_date())
>>> from time_1 import Time
>>> t1 = Time("14:35:12")
>>> t1.seconds
12
>>> t1.seconds = 5000000000
>>> t1.seconds
5000000000
t1 = Time("09:45:00")
print(t1)
>>> from time_3 import Time
>>> t = Time("09:30:00")
>>> print(t)
<time_3.Time object at 0x1013e8358>
# returns a string formated as follows
# H[H] hours M[M] minutes S[S] seconds
def __str__(seconds):
hours = seconds // (60 * 60)
remainder = seconds % (60 * 60)
minutes = remainder // 60
seconds = remainder % 60
return str(hours) + " hours " + str(minutes)+ " minutes " + str(seconds) + " seconds
def __init__(self, manufacturer, model, serial_number, processor, ram, hostname, disk_size):
self.__manufacturer = manufacturer
self.__model = model
self.__serial_number = serial_number
self.__processor = processor
self.__ram = ram
self.__hostname = hostname
self.__disk_size = disk_size
def get_manufacturer(self):
return self.__manufacturer
def get_model(self):
return self.__model
def get_serial_number(self):
return self.__serial_number
def get_processor(self):
return self.__processor
def get_processor(self):
return self.__processor
def get_ram(self):
return self.__ram
def get_hostname(self):
return self.__hostname
def get_disk_size(self):
return self.__disk_size
def set_ram(self, ram):
self.__ram = ram
def set_hostname(self, hostname):
self.__hostname = hostname
def set_disk_size(self, disk_size):
self.__disk_size = disk_siz
import statements need to be at the top of the file ...from student import Student import pickle class Section: ...
intfloatboolstr| Operator | Magic Method |
|---|---|
int |
__int__(self) |
float |
__float__(self) |
bool |
__bool__(self) |
str |
__str__(self) |
def count_down(num):
print(num)
if num > 1:
count_down(num - 1)
10 9 8 7 6 5 4 3 2 1
n!
n! = (n-1)! * n
1! = 1
def factorial(num):
if num == 1:
return 1
else:
return factorial(num -1) * num
>>> print("5!:",factorial(5))
5!: 120
1 1
1 1 2 3 5 8 13 21 34 55
F(n) = F(n - 1) + F(n - 2)
F(1) = 1 F(2) = 1
def fibonacci(num):
if num == 1 or num == 2:
return 1
else:
return fibonacci(num - 1) + fibonacci(num - 2)
set count to 0
get a list of all the entries in the current directory
for each entry
if the entry is a directory
increase count by 1
run the function on this directory and increase count by what it returns
return the count
def dir_count(path):
count = 0
entries = os.listdir(path)
for entry in entries:
entry_path = path + "/" + entry
if os.path.isdir(entry_path):
count += 1
count += dir_count(entry_path)
return count