Sequences

The questions below are due on Friday June 21, 2024; 10:00:00 PM.
 
You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
For each of the expressions below, specify its value. If evaluating the expression would generate an error, type error in the box. Be careful of types! Assume the following assignment has been made:
x = [1.1, 2, [3, 'tomato', 4], 'cat']
x[2]  
tuple(x[-1]) == ("cat",)  
type(x[-1]) == str and isinstance(x[0], (int, float))  
x[2][-1]  
x[4]  
len(x[-1])  
[1, 2] + x[1]  
[1,2] + [3, x[1]]  
"na"*4 + " batman"  
(4, 7, 5) == [4, 7, 5]  
(4, 7, 5)[0] == [4, 7, 5][0]  
'tomato' in x  
str(x[0])  
x[:2] + x[-1]  
x[-1].replace('c', 'b')  
list(x[-1].upper())  
Next Exercise: Environment Diagrams
Back to exercises