Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Engineering LibreTexts

3.6: Chapter Summary

( \newcommand{\kernel}{\mathrm{null}\,}\)

Highlights from this chapter include:

  • A string is a sequence of values that represents Unicode code points.
  • An index refers to the position of a value in a sequence (string, list, tuple).
  • Positive indexes range from 0 to length–1. Negative indexes range from –1 to –length.
  • F-strings are a convenient way to print multiple outputs and format integers and floats.
  • Variables refer to objects. Memory diagrams are useful for drawing variables and objects.
  • A list object can be used to refer to multiple objects, by index, using the same variable.
  • A tuple is similar to a list, but uses parentheses and cannot be changed once created.
Code Description
ord(c)
Gets an integer representing the Unicode code point of a character.
chr(i)
Converts a Unicode code point (integer) into a One-character string.
'\n'
Escape sequence for the newline character.
'\t'
Escape sequence for the tab character.
f"{number:.02d}"
Creates a string by formatting an integer to be at least two digits.
f"{number:.2f}"
Creates a string by formatting a float to have two decimal places.
id(object)
Gets the identity (memory location) of an object.
type(object)
Gets the type (class name) of an object.
my_list = ["a", "b", "c"]
Creates a list of three strings.
my_tuple = ("a", "b", "c")
Creates a tuple of three strings.
my_list[0]

Gets the first element ("a") of my_tuple.

my_tuple[-1]

Gets the last element ("c") of my_tuple.

Table 3.5 Chapter 3 reference.

This page titled 3.6: Chapter Summary is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by OpenStax via source content that was edited to the style and standards of the LibreTexts platform.

  • Was this article helpful?

Support Center

How can we help?