PROG12583
Programming Foundations - Python
Final Review
Topics
PROG10082 – Object Oriented Programming
• Summary of Topics
• Exam Policies and Rules
• Multiple Choice Questions
Java 1
• Short Answer Questions
• Coding Questions
• Quiz 5
2
Summary of Topics
PROG10082 – Object Oriented Programming
• Data Validations, loop terminations and nested programming structures:
Validating the user input
Loop control, sentinel values, priming read
break and continue statements
Nested loops. Nesting different programming structures.
Java 1
• Python Sequences and collections.
Lists. Accessing list elements. List methods and list slicing.
Tuples, dictionaries and sets
Defining different types of collections and accessing their data.
Common methods and functions used with different collections.
Using loops with collections
3
Summary of Topics (continue)
PROG10082 – Object Oriented Programming
• User-defined functions
Defining and calling void functions and value returning functions
Local and global variables and their scope
Program modularization and using functions as modules. Importing modules and
using them in different programs.
Java 1
Differences between void functions and value-returning functions.
Passing and returning mutable and immutable objects between functions.
• Searching and sorting algorithms
Linear search and binary search. Identifying the type of search and the logic used
in each search.
Bubble sort and insertion sort. How each algorithm works. Identifying them in a
given code of pseudocode.
Using searching and sorting algorithms with sequences.
List's sort() method. Using sorted() function for sorting data with collections.
4
Summary of Topics (continue)
PROG10082 – Object Oriented Programming
• Python files
How files are created and used for reading and writing data in Python.
The syntaxes for opening and closing files for reading and writing.
Reading and writing numeric data types in Python
Writing and reading data as part of a record in a file. Common field separators.
Java 1
• Errors and exceptions
Types of errors in programming
What are exceptions, when do they occur and how are they handled?
Different types of built-in exceptions in Python
Handling multiple exceptions
Raising exceptions. Using exceptions for data validations.
5
Summary of Topics (continue)
PROG10082 – Object Oriented Programming
• Object Oriented Programming
What are procedural programming and object-oriented programming?
What are classes? How are they created? What do they contain?
What are attributes? How are they defined?
What are methods? what do they represent? How are they created? What is self?
Java 1
Class UML diagrams. What do they contain?
What are __init__ and __str__ methods? What are they used for?
What are class instances? Creating class instances.
Encapsulation and attribute hiding.
How to access hidden class attributes? What are accessors and mutators?
Raising exceptions inside mutators and constructors.
Class attributes and class methods..
Object and class relationships.
Writing programs using object-oriented design.
6
Conventions
PROG10082 – Object Oriented Programming
• Coding Conventions
Variable Names
lowercase
meaningful names
Java 1
Camel case or underscore separated
Constants
Must be created when literals are part of the logic
UPPER case
Underscore separated
Indentation
Code must be properly indented
In Python improper indentations cause errors
In quizzes and midterm use the space bar to indent your code
7
Study Hints:
PROG10082 – Object Oriented Programming
• Do the exercises at the end of each lesson on SLATE.
• Check each lesson for the book chapters/pages we covered.
• Read the chapter sections and look for words in bold or italics, these are
terms and concepts you'll need to know.
Java 1
• Use the book's index to look up things you aren't sure about.
• Read SLATE postings for each lesson.
They often contain extra information or rephrase and emphasize the most
important information from the text.
8
Exam Policies and Rules
PROG10082 – Object Oriented Programming
• Exam will be two hours long
• The exam will be using assessments - quizzes on SLATE
No textbooks, notes, reference sheets or other material are allowed
Java 1
• DO NOT forget your student ID
• All cellphones must be turned off or silenced and kept away.
You are not allowed to answer your phone or use any electronic devices including
calculators during the exam.
• You may not leave the room for any reason during exam.
• Remember, this exam is worth 30% of your final mark.
9
Exam Policies and Rules
PROG10082 – Object Oriented Programming
• The exam will include the following types of questions:
• Multiple-Choice and True/False.
• Short-Answer questions, such as:
define something
Java 1
fill-in-the-blank
write one or two code statements to do something
locate, identify and fix coding errors
show the output of a code segment
• Coding Questions
Two or three questions that ask you to hand-write code to perform a task.
10
Online Exam Policies and Rules
PROG10082 – Object Oriented Programming
• The exam will start at the beginning of our regular class
• You must start the exam within 20 minutes of the exam start time.
• There are no makeup exams
Java 1
• Plan ahead!
Leave earlier than the usual days.
11
Exam Format
PROG10082 – Object Oriented Programming
• Multiple choice (approx. 40 - 50% of marks)
Very similar to questions you have seen in in-class quizzes
• Short answers (10% - 20% marks)
Define a concept
Java 1
Fill-in-the-blank
Write one or two statements to perform a task
Identify and fix coding errors
Show the output of a code segment
• Programming questions (20% - 30% of marks)
Write statements that perform a task
Write an entire program that solves a problem
12
Review
PROG10082 – Object Oriented Programming
• The textbook
Introducing Python, by Bill Lubanovic
Chapters: 3, 4, 5, 6
Foundations of Python Programming:
Sections: 6, 7, 8, 11, 12, 14, 16, 19, 20
Java 1
• Slate
Lessons 7.1 – 13.2
• In-class Exercises
• Assignments
13
•
Exercises
See Exercises on Slate.
PROG10082 – Object Oriented Programming
15
Java 1
Next Class
PROG10082 – Object Oriented Programming
• Next class is the Final Exam
• Review all topics since the beginning
• Make sure to start in time
Java 1
Missing this exam means that you will miss 30% from your final mark
16