# Python Assessment

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

1. Simple and nested loops.
2. Functions
3. Bit operations
5. 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.

# Basic (BASIC) level programs

## Topics

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

## Problems

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

# Fundamental Data Structures

List, tuple, set, frozenset, dictionary

## Topics

1. Creation of, and basic operations on, all five data structures.
2. Slicing.
3. Selecting the appropriate data structure.
4. Comprehensions.

## Problems

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

i# Medium: Multiple choice? A few scenarios, pick the data structure: Example: Look­ing 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.

1. 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

1. Basic definition.
2. Test knowledge of builtin functions.
3. Recursion.
4. Decorators? Move this to classes?

## Problems

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

# Iterators and Generators

## Topics

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

## Problems

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

# Classes

## Topics

1. Basic definition.
2. Dunder methods, class based iterators.
3. Inheritance. Decorators.
4. Privacy conventions.

## Problems

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