>>> text = "Clubes de Ciencia" >>> print(text[0], text[1], text[2], text[3], text[-3], text[-2], text[-1]) C l u b c i a >>> text[-7:] # start, stop 'Ciencia' >>> text[0:5] # start, stop 'Clube' >>> text[::2] # start, stop, step 'Cue eCeca' >>> text[::-1] # start, stop, step 'aicneiC ed sebulC'
>>> text = "Clubes de Ciencia" >>> print(text[0], text[1], text[2], text[3], text[-3], text[-2], text[-1])
C l u b c i a
>>> text[-7:] # start, stop
'Ciencia'
>>> text[0:5] # start, stop
'Clube'
>>> text[::2] # start, stop, step
'Cue eCeca'
>>> text[::-1] # start, stop, step
'aicneiC ed sebulC'
>>> text[0] = 'K' TypeError: 'str' object does not support item assignment >>> text_lowercase = text.lower() >>> text_lowercase 'clubes de ciencia'
>>> text[0] = 'K'
TypeError: 'str' object does not support item assignment
>>> text_lowercase = text.lower() >>> text_lowercase
'clubes de ciencia'
>>> 'hello' + ' ' + 'world' 'hello world' >>> 'hello'*3 'hellohellohello' >>> 'g' in 'hello' False
>>> 'hello' + ' ' + 'world'
'hello world'
>>> 'hello'*3
'hellohellohello'
>>> 'g' in 'hello'
False
>>> x = (0,) >>> y = (1, "Two", 3) >>> y[1] 'Two' >>> x = [0, 1, 2] >>> y = [3, 4, 5] >>> x + y [0, 1, 2, 3, 4, 5] >>> x[1:-1] [1, 2, 3, 4]
>>> x = (0,) >>> y = (1, "Two", 3) >>> y[1]
'Two'
>>> x = [0, 1, 2] >>> y = [3, 4, 5] >>> x + y
[0, 1, 2, 3, 4, 5]
>>> x[1:-1]
[1, 2, 3, 4]
>>> x = [1,2] >>> x[1] = 'Two' >>> x.append(3) >>> x.extend([4,'Five',6]) >>> x [1, 'Two', 3, 4, 'Five', 6]
>>> x = [1,2] >>> x[1] = 'Two' >>> x.append(3) >>> x.extend([4,'Five',6]) >>> x
[1, 'Two', 3, 4, 'Five', 6]
>>> x = set([1,3,2,2,2,3]) >>> print(x) {1, 2, 3} >>> 4 in x False
>>> x = set([1,3,2,2,2,3]) >>> print(x)
{1, 2, 3}
>>> 4 in x
>>> x.add(4) >>> 4 in x True
>>> x.add(4) >>> 4 in x
True
>>> fruits = {'apples': 3, 'oranges': 1} >>> fruits['bananas'] = 2 >>> list(fruits.keys()) ['apples', 'bananas', 'oranges']>>> list(fruits.values()) [3, 2, 1]
>>> fruits = {'apples': 3, 'oranges': 1} >>> fruits['bananas'] = 2 >>> list(fruits.keys())
['apples', 'bananas', 'oranges']
>>> list(fruits.values())
[3, 2, 1]
SyntaxError: not a chance
>>> print_lyrics() I'm a lumberjack, and I'm okay. I sleep all night and I work all day.
>>> print_lyrics()
I'm a lumberjack, and I'm okay. I sleep all night and I work all day.
>>>greet("Mariana") Hola, Mariana!
>>>greet("Mariana")
Hola, Mariana!
>>>print(greet("Mariana")) Hola, Mariana!
>>>print(greet("Mariana"))
>>> name = "Shaq" >>> height_in_cm = 216
>>> "Hi, my name is %s and I am %.2f meters tall" % (name, height_in_cm / 100)
>>> "Hi, my name is {} and I am {} meters tall".format(name, height_in_cm / 100)