I&C SCI 31 Study Guide - Final Guide: Docstring, Empty Set, Boolean Expression

1885 views2 pages

Document Summary

List_of_namedtuple. sort(key=attrgetter( field"), reverse=true, or false) from collection import namedtuple (parameters: title", field field field ") replace the field of the namedtuple (parameters: field = item) From operator import attrgetter returns the list of namedtuple based on a field that isn"t the first. The key could also be a function that is defined to return the field to sort by. {:#d}, {:#s} the number dictates the size of the field based on the number of characters. Str. translate(transtable) translates the str using the argument that is a translation table ^ Datetime. strptime( str/str/str", mode/mode/mode") from datetime import datetime returns str argument in the form of datetime second argument dictates format through mode with separators in between. %m = month as zero padded digit %d = day as a zero padded digit. / could be - or . etc as long as they are consistent with both parameters.