Information for the Written Exam
Date, Time, and Place ("Normal Season", a.k.a. "Época Normal")
Valuation:
As discussed on the evaluation page and Sigarra, this exam is worth 50% of the grade on this course (the other 50% come from the practical tests and exercises during practical classes).
For improvements from the previous year, this written exam is worth 100% of the grade.
Exam Sample Questions:
The following PDF contains some examples of exam questions (we want to give you an idea of some the types of questions we can ask on the exam). The number and difficulty of questions of the real exam will be calibrated for its duration.
Goals for the Final Exam
Items marked with an asterisk (*) are for valorization, that is, aimed at students who want to get a grade above 18.
Fundamentals
Programming Fundamentals
- Understand the concept of a variable as a container for storing data.
- Understand the difference between a statement and an expression.
- Understand the difference between arithmetic and logical operators.
- Be able to write simple programs that combine multiple programming concepts (e.g., input, processing, output).
Python Fundamentals
- Know the basic usage of the
input()
and print()
functions.
- Know the primary data types in Python:
int
, float
, str
, and bool
.
- Know the
type()
function and how to perform explicit type conversions (e.g., using int()
, float()
, and str()
).
- Know the rules for naming variables and the meaning of reserved keywords.
- Be able to assign values to variables and evaluate Python expressions.
- Know the main arithmetic operators (
+
, -
, *
, /
, //
, %
, **
), their functionality, and precedence rules.
- Know how to combine and predict the result of expressions using arithmetic and logical operators.
Conditionals and Program Flow
Boolean Values
- Understand the role of Boolean values (
True
and False
) in decision-making within a program.
- Understand the difference between comparison operators (e.g.,
==
, !=
, <
, >
, <=
, >=
).
- Know how to interpret Boolean expressions and predict their result.
- Know how logical operators (
and
, or
, not
) are used to combine Boolean expressions.
Conditional Execution (if-else
statements)
- Know how to use the
if
statement to execute code based on a condition.
- Know how to use the
else
statement to provide an alternative when the condition is not met.
- Know how to write chained conditionals (i.e., multiple
if-elif-else
statements) to evaluate multiple conditions in sequence.
- Understand how to write nested conditionals, where an
if
statement appears inside another if
block.
Program Flow (for
and while
loops)
- Understand the concept of iteration and how it is used to repeat code based on conditions.
- Know how variables are updated during iteration to track changes within loops.
- Know how to write a
for
loop using the range()
function or by traversing an iterable (e.g., a list).
- Know how to write a
while
loop using a condition to control/stop the loop.
- Understand the behavior of the
break
statement to exit a loop early.
- Understand the behavior of the
continue
statement to skip the current iteration and move to the next.
Functions
Basic Concepts
- Understand the concept of a function as a reusable block of code that performs a specific task.
- Know how to define a function using the
def
keyword and how to call it in a program.
- Understand how functions can receive arguments that are later assigned parameters (during function calls).
- Understand how functions that return values can pass data back to the calling code using the
return
statement.
- Understand the concept of flow of execution in a program, including how the program jumps to a function and returns after execution.
Advanced Concepts
- Be able to create Boolean functions that return
True
or False
based on conditions and how to use them in conditional statements.
- Be able to design functions that return multiple values using tuples or lists.
- Understand the concept of lambda functions and how to define and use them. (*)
- Understand and implement higher-order functions (functions that take other functions as arguments or return functions). (*)
Strings
Basic Concepts
- Understand how to create and manipulate strings in Python, using basic string operations such as concatenation and repetition (
+
, *
).
- Understand string formatting techniques, such as using f-strings to embed variables inside strings.
- Know how to perform indexing and slicing operations on strings (
str[idx]
, str[start:end]
).
- Understand that strings are immutable in Python.
Advanced Concepts
- Know how to use
ord()
to get the Unicode integer value of a character and chr()
to convert a Unicode value back to a character.
- Identify common string constants and know how to use
isX
methods (e.g., isalpha()
, isdigit()
) to check for certain string properties.
- Know how to split strings using
.split()
and join strings using .join()
, including working with delimiters and whitespace.
Algorithms and Structured Programing
Concepts
- Learn how to understand a problem by carefully reading and analyzing it, ensuring that you fully comprehend what is being asked.
- Know how to organize your solutions logically before jumping into writing the code.
- Understand modular programming (dividing the code into smaller, more manageable pieces or functions) and incremental development (testing each block of code before moving on to the next).
- Understand the importance and best practices in algorithm correctness and efficiency.
Applications
- Understand how to break complex problems statements into simpler tasks.
- Know how to break and organize a large program into smaller functions or files (modules).
- Know how to implement helper functions to simplify the main logic of your programs.
- Know how to import and use standard libraries to make code more modular.
- Know how to test your programs.
Data Structures
Concepts
- Understand the concepts of iterables, sequences, and the distinction between mutable and immutable data types.
- Understand the difference between tuples, lists, dictionaries, and sets in terms of mutability and use cases.
- Identify the situations where using a specific data structure is more appropriate than using another (e.g., tuples vs. lists vs. dictionaries vs. sets).
- Understand and apply algorithmic patterns using data structures (e.g., extracting elements based on conditions; applying a transformation to each element; combining elements into a single value).
Tuples
- Know how to create and access elements in a tuple.
- Know how to perform basic tuple operations (e.g., traversing, concatenation, multiplcation/repetition, slicing).
- Understand tuple packing and unpacking.
- Understand the immutability of tuples and its implications.
- Understand and apply nested tuples in more complex data structures.
- Know how to apply built-in functions like
len()
, max()
, min()
, sum()
with tuples.
Lists
- Know how to create, access, and modify elements in a list.
- Know how to perform list operations (e.g., traversing, slicing, appending, extending, removing, and sorting).
- Understand the mutability of lists and its implications.
- Understand and apply nested lists in more complex data structures.
- Know how to apply built-in functions like
len()
, max()
, min()
, sum()
with lists.
- Know and use common list methods (e.g.,
append
, extend
, insert
, remove
, clear
, reverse
, sort
).
- Understand how equality (
==
) and ordering (<
, >
, <=
, >=
) comparisons work on lists.
- Understand the difference between copying by reference and copying by value and know how to create shallow copies and deep copies of lists (e.g., using
copy()
). (*)
- Know how to use higher-order functions (e.g.,
map
, filter
, reduce
) with lists. (*)
- Understand list comprehensions and their advantages in creating and transforming lists. (*)
Dictionaries
- Understand the dictionary data structure as a collection of key-value pairs.
- Understand how to iterate over dictionaries effectively using loops.
- Be able to combine dictionaries with other data structures (e.g., dictionaries of lists).
- Know how to create dictionaries using literals (
{}
) or the dict()
constructor.
- Understand the rules for keys (e.g., they must be immutable types like strings, numbers, booleans, or tuples).
- Know how to access, add, update, and delete key-value pairs in a dictionary.
- Know how to use key dictionary methods, such as
keys()
, values()
, items()
, clear()
, get()
, pop()
, update()
.
Sets
- Understand the set data structure as a collection of unique, unordered elements.
- Understand set operators:
union (
|
), intersection (&
), difference (-
), symmetric difference (^
) and subset relationships (<
, >
, <=
, >=
).
- Be able to combine sets with other data structures (e.g., lists of sets, sets of tuples).
- Know how to create sets using literals (
{}
) and the set()
constructor.
- Know how to iterate over sets and how to add and remove elements using methods like
add()
and remove()
or discard()
.
Recursion
Concepts
- Understand the concept of recursion as a problem-solving approach where a function calls itself.
- Understand the base case and recursive case as fundamental components of any recursive function.
- Be able to identify problems that can be effectively solved using recursion.
- Know how to break down a problem recursively into smaller subproblems.
Applications
- Understand and implement simple recursive patterns, such as summing a list recursively, factorial computation, fibonacci sequence generation, flattening nested lists.
- Understand and implement more advanced recursive algorithms such as generating permutations or combinations (without using
itertools
🙃), and navigating multi-dimensional structures (e.g., grids). (*)
Variable Scope and Modules
Variable Scope
- Understand the concept of variable scope as the region of a program where a variable is accessible.
- Know Python's LEGB rule (Local, Enclosing, Global, Built-in) for variable lookup and resolution.
- Be able to predict which variable is being accessed or modified based on its scope.
- Understand and use the
nonlocal
and global
keywords. (*)
Modules
- Understand the concept of modules as reusable Python files containing functions, variables, and classes.
- Know how namespaces are managed in Python and how they interact with modules.
- Understand the purpose and functionality of import statements, including
"import ___"
, "from ___ import ___"
, and "import ___ as ___"
.
- Understand the use of the dot operator (
.
) to access module attributes and functions.
- Be able to import and use standard library modules like
math
and random
. (*)
Errors and Exceptions
Concepts
- Be able to identify the main types of errors in Python: syntax errors, runtime errors, and semantic errors.
- Understand runtime errors and their potential causes during program execution.
Applications
- Be able to predict the common built-in exceptions in Python, such as
TypeError
, ValueError
, KeyError
, and IndexError
.
- Know how to implement the
try-except
block for catching and handling exceptions.
- Know how to use multiple
except
blocks to handle different types of exceptions.
- Be able to use the
else
and finally
clauses in conjunction with try-except
blocks to specify additional functionality. (*)
- Understand how to raise custom exceptions using the
raise
statement. (*)
- Know how to use assertions (using the
assert
statement) to validate conditions during development and testing. (*)
Files and Object-Oriented Programming
For the written exam we have decided not to include these topics.