Lab 5: General Importance Style Conventions/Advice

Based on observing student's code in recent lectures and today's lab, Prof. Lyn would like to emphasize the following about generalk coding style guidelines for the course, as well as some guidelines specific to loops.

Familiarize yourself with the Code Style Guide

Especially if you're not familiar with it already, you should frequently consult the Code Style Guide for general guidelines about coding style for the course

General Naming Guidelines for Parameters and Local Variables

In general, you should avoid very short (especially single-letter) or otherwise unhelpful parameter and local variable names. There are a few exceptions: it's sometimes OK to use single-letter variable names (or single letters followed by a digit) in cases where the letter implies a type (but longer names are often more helpful). For example:

Note it's often OK to use type names like int, str, bool, list, dict (and variants thereof) also as parameter or local variable names. But you do need to be careful not to shadow another use of these name in your context. E.g., you can't use int, str, list, etc. as a funtion parameter if you also want to call them as built-in functions in the function body!

Specific Naming Guidlines for Sequences and Loops

Table of Contents