# Python Assessment

The C assessment exam has used questions on specific topics, often those in the following list.

- Simple and nested loops.
- Functions
- Bit operations
- Linked list
- Binary trees

This page is an attempt to identify such a set of topics for Python. The focus is on fundamentals, not modules. No imports allowed. For each problem type, some topics are listed. Then example problems are given (or will be someday), and split into three categories: Easy, Medium, and Hard. A typical exam might use one each from the Easy and Hard categories, and three from the Medium category.

## Contents

# Basic (BASIC) level programs

## Topics

- Basic data types: string, numeric (not Complex), Boolean
- Reading and writing: input and print.
- Type conversions: string to/from numeric.
- Algebraic expressions. Assignment statements.

## Problems

- Easy: Celsius to Fahrenheit conversion.
- Medium: Temperature conversion with inputs like: 30F, 40C, etc.
- Harder: Real solutions to quadratic equations.

# Fundamental Data Structures

List, tuple, set, frozenset, dictionary

## Topics

- Creation of, and basic operations on, all five data structures.
- Slicing.
- Selecting the appropriate data structure.
- Comprehensions.

## Problems

- Easy: Find words common to two lists, read from 2 column data .le.
- Medium: Find words common to two of three lists.

i# Medium: Multiple choice? A few scenarios, pick the data structure: Example: Looking up words in a foxed list of words. Which of the five do we use? Or, looking up words in a changing list of words. Looking up and counting frequencies for a list of words.

- Harder (Code golf with comprehensions?) Sort, max, min problems. Example: Sort a list of words by the number of vowels in the word. Example: Find the number (in a list) with the most one bits in its binary representation.

# Functions

## Topics

- Basic definition.
- Test knowledge of builtin functions.
- Recursion.
- Decorators? Move this to classes?

## Problems

- Easy: Defining simple functions. Position and named parameters.
- Medium: Recursion with memoization (functools not allowed).
- Hard: Functions returning functions: return a linear or quadratic function given coefficients.

# Iterators and Generators

## Topics

- Using iterators: for, next, iter.
- Common iterators: lists, tuples, dictionaries, range, zip, enumerate, .le descriptors, et cetera.
- Creating iterators: class-based iterations (move to classes?).

## Problems

- Easy: nested loops, one of Rob’s patterns of characters.
- Medium: nested loops, one of Rob’s harder patterns.
- Medium: Given class definition: write a method to do something.
- Hard: (generators) Construct generator for words from text .le.

# Classes

## Topics

- Basic definition.
- Dunder methods, class based iterators.
- Inheritance. Decorators.
- Privacy conventions.

## Problems

- Easy: De.ne a Point class; add a few methods for distance, norms.
- Medium: Binary tree class, with the usual methods, a couple dunders (in, len, str, add, eq, invert).
- Hard: Subset frequency counting trie. Given a big set, .nd all subsets that appear as subsets in at least r of the sets.