4. The Core Python Language II
Examples (21)
- E4.1Assignment vs. the comparison operator
- E4.2Exception tracebacks
- E4.3String representation of vectors
- E4.4Vector cross product
- E4.5try ... except ... else ... finally
- E4.6A simple dictionary of Roman numerals
- E4.7A simple database of astronomical objects
- E4.8Word lengths in the first line of the Gettysburg Address
- E4.9Mersenne primes
- E4.10The matrix transpose by list comprehension
- E4.11lambda functions
- E4.12Sorting methods
- E4.13Triangular numbers
- E4.14Assignment expressions (the walrus operator)
- E4.15Issuing a usage method
- E4.16Batch renaming of files
- E4.17The Monty Hall problem
- E4.18A simple Python class
- E4.19The random-flight polymer
- E4.20A 2D vector class
- E4.21A simple 2D molecular dynamics simulation
Questions (14)
- Q4.1.1The else block of a try ... except clause
- Q4.1.2The finally block of a try ... except clause
- Q4.2.1Determining if a string is a pangram
- Q4.2.2Removing duplicates from a list
- Q4.2.3Defining set objects
- Q4.2.4frozenset
- Q4.2.5Grouping words by their length using a defaultdict
- Q4.3.1List comprehension and lambda functions
- Q4.3.2Mystery list comprehension
- Q4.3.3Various list comprehensions
- Q4.3.4Sorting a dictionary
- Q4.3.5The "jump the five" cypher
- Q4.3.6Sorting a list containing None
- Q4.3.7Using an assignment expression
Problems (23)
- P4.1.1Average air-speed of an unladen African swallow
- P4.1.2String representation of a vector
- P4.1.3Raising an exception on \(0^0\)
- P4.2.1Resistor colour codes
- P4.2.2The most 100 frequent words in Moby Dick
- P4.2.3A reverse polish notation calculator
- P4.2.4A Morse Code generator
- P4.2.5Shark species
- P4.3.1Matrix trace
- P4.3.2The ROT-13 cypher
- P4.3.3Rule 30
- P4.3.4IBAN code lengths
- P4.3.5Power sets
- P4.3.6Word analysis
- P4.4.1Hailstone sequence generator with a usage message
- P4.4.2The haversine formula
- P4.4.3Creating a set of SVG image files
- P4.4.4Batch renaming of files
- P4.6.1Modifying the BankAccount class
- P4.6.2Saving a polymer image
- P4.6.3The Yale Bright Star catalog
- P4.6.4A simple class for linear regression
- P4.6.5A one-based list