Enter the following code into an input cell in a Sage notebook. Alternatively, you can create a new text file containing the code, save it with a .sage extension, and use the load
command to run it in Sage.
# Creating lists with Python list1 = ['a', 'b', 'c', 'd', 'e'] print("A list of characters: " + str(list1)) list2 = [] print("\nAn empty list: " + str(list2)) list2.append('f') list2.append('g') print("After appending items: " + str(list2)) list3 = list() list3.extend(list1) print("\nList 3 after extending: " + str(list3)) list3.append(list2) print("List 3 after appending a list:" + str(list3)) list_of_ints = range(1, 11, 2) print("\nA list of integers: " + str(list_of_ints)) # Sage-specific list creation list_of_floats = srange(0.0, 2*n(pi), step=n(pi)/2, universe=RDF) print("A list of real numbers:") print(list_of_floats) print("A list of symbols:") print(srange(0, 2*pi, pi/4)) list_of_ints_2 = [1..11, step=2] print("Another list of integers: " +...