Last login: Sat Nov 28 10:32:52 on console MacBook-Pro-von-agcc:~ anagabrielacastilhocaesar$ MacBook-Pro-von-agcc:~ anagabrielacastilhocaesar$ python3 Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> a = 2 >>> b = 3 >>> c = 4E-2 >>> a 2 >>> b 3 >>> c 0.04 >>> d = 2.0 >>> e = 3.4 >>> print ('Hello, World!') Hello, World! >>> type (a) <class 'int'> >>> n = True >>> m = False >>> a, b, c = File "<stdin>", line 1 a, b, c = ^ SyntaxError: invalid syntax >>> a = b >>> import keyword >>> print keyword.kwlist File "<stdin>", line 1 print keyword.kwlist ^ SyntaxError: Missing parentheses in call to 'print' >>> print (keyword.kwlist) ['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] >>> a, b, c = 'Jet' >>> a, b, c ('J', 'e', 't') >>> a, b, c = 1, False, 3.5 >>> a, b, c = 1, False, 'pylaaaadies' >>> type (a) <class 'int'> >>> h = 2 + 3j >>> g = 4 + 4x File "<stdin>", line 1 g = 4 + 4x ^ SyntaxError: invalid syntax >>> a = 2 >>> b = 3 >>> c = (a + b - 2 * a + a ** a) / 5 >>> c 1.0 >>> 10 / 8 1.25 >>> 10 % 8 2 >>> a = 2 >>> b = 3 >>> a > b False >>> b > a True >>> a ==b False >>> a != b True >>> c = 2.0 >>> d = '2.0' >>> a + b 5 >>> b ** a 9 >>> a + c 4.0 >>> c + d Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'float' and 'str' >>> a + d Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> a = 2 >>> b = 3 >>> a + d Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> c + d Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'float' and 'str' >>> a = c >>> a = 2 >>> c = 2.0 >>> a == c True >>> a <= c True >>> c == d False >>> b **c 9.0 >>> b + a / c ** d Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for ** or pow(): 'float' and 'str' >>> a > b and c < d False >>> not(a != b and b <= (a**2)-1) False >>> 'Gabriela' + 'Caesar' 'GabrielaCaesar' >>> 'Gabriela' + [blank] + 'Caesar' Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'blank' is not defined >>> 'Gabriela ' + 'Caesar' 'Gabriela Caesar' >>> print ('Gabriela \tCaesar') Gabriela Caesar >>> print ('Gabriela \tCaesar') Gabriela Caesar >>> #tab ... >>> print ('Gabriela \nCaesar') Gabriela Caesar >>> #proxima linha ... >>> 'GABRIELA'.upper () == 'gabriela' False >>> 'GABRIela'.lowe () == 'gabriela' Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'lowe' >>> 'GaBRIela'lower() == 'gabriela' File "<stdin>", line 1 'GaBRIela'lower() == 'gabriela' ^ SyntaxError: invalid syntax >>> 'GaBRIELa'.lower() == 'gabriela' True >>> a = File "<stdin>", line 1 a = ^ SyntaxError: invalid syntax >>> a = 'Seu Madruga' >>> a[0] 'S' >>> a[5] 'a' >>> a[-5] 'd' >>> a[4:11:2] 'Mdua' >>> a[1:6:8:3] File "<stdin>", line 1 a[1:6:8:3] ^ SyntaxError: invalid syntax >>> a[3:8:5] ' ' >>> a[::11] 'S' >>> a[3:5:8] ' ' >>> a[::-1] 'agurdaM ueS' >>> a = 'dona clotilde' >>> a.upper() 'DONA CLOTILDE' >>> a.lower() 'dona clotilde' >>> a(::-1) File "<stdin>", line 1 a(::-1) ^ SyntaxError: invalid syntax >>> a[::-1] 'edlitolc anod' >>> varAGCC = 'Godines' >>> varAGCC(6) = 'z' File "<stdin>", line 1 SyntaxError: can't assign to function call >>> varagcc = 'Godines' >>> varagcc[6] == 'z' False >>> varagcc[6] = 'z' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment >>> varagcc[6] % 'z' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: not all arguments converted during string formatting >>> varagcc[::-1] = 'z' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment >>> varagcc[0:6] 'Godine' >>> varagcc[0:6]+z Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'z' is not defined >>> a = 'Inconstitucionalissimamente' >>> len(a) 27 >>> a.startswith('N') False >>> a.startswith('I') True >>> a.endswith('e') True >>> b = """Não contavam com minha astúcia! Sigam-me os bons!""" >>> b.endswith('!') True >>> >>> #aspas triplas deixam o codigo com espacamento e forma com que eu deixei ... b.startswith('N') True >>> b.find('!') 30 >>> b.find('!', 31) 48 >>> b.find('?') -1 >>> b.find('ã') 1 >>> a.find('m', 25) -1 >>> a.find('m') 20 >>> a.find('m', 21) 22 >>> a.replace('contavam', 'imaginavam') 'Inconstitucionalissimamente' >>> a 'Inconstitucionalissimamente' >>> b.replace('contavam', 'imaginavam') 'Não imaginavam com minha astúcia! Sigam-me os bons!' >>> b.delete('com') Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'delete' >>> b.replace('imaginavam com','esperavam') 'Não contavam com minha astúcia! Sigam-me os bons!' >>> b.replace('contavam com', 'esperavam') 'Não esperavam minha astúcia! Sigam-me os bons!' >>> a = [ 'Chaves', 8, True] >>> print(a[0]) Chaves >>> print(a[1]) 8 >>> print(a[2]) True >>> print(a[3]) Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range >>> a = ['Gabriela ', 'é ', 'muito ', 'muito ', 'muito ', 'muito '] >>> a.append('Linda', 'Idiota', 'Feia') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: append() takes exactly one argument (3 given) >>> a.append('Linda') >>> print(a) ['Gabriela ', 'é ', 'muito ', 'muito ', 'muito ', 'muito ', 'Linda'] >>> a.remove( ... chas = ('Camomila', 'Hortela', 'Cidreira') ... '/'.join(chas) File "<stdin>", line 3 '/'.join(chas) ^ SyntaxError: invalid syntax >>> chas = ('Camomila', 'Hortela', 'Cidreira') >>> '/'.join(chas) 'Camomila/Hortela/Cidreira' >>> '1,2,3,4'.split(',') ['1', '2', '3', '4'] >>> 'abra,ca,da,bra'.split(',') ['abra', 'ca', 'da', 'bra'] >>> 'eu,me,chamo,gabriela,caesar,e,eu,tenho,23,anos'.split(',') ['eu', 'me', 'chamo', 'gabriela', 'caesar', 'e', 'eu', 'tenho', '23', 'anos'] >>> variavel001 = 'eu,me,chamo,gabriela,caesar,e,eu,tenho,23,anos' >>> variavel001 = ('eu', 'me') >>> variavel002 = ['eu', 'me22') File "<stdin>", line 1 variavel002 = ['eu', 'me22') ^ SyntaxError: invalid syntax >>> variavel002 = ['eu', 'odeio'] >>> dir(variavel001) ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index'] >>> dir(variavel002) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] >>> variable = 'vc nao vai com a minha cara?' >>> len(variable) 28 >>> variable.startswith('v') True >>> variable.endswith('?') True >>> variable.find('?') 27 >>> variable.replace('?', '!') 'vc nao vai com a minha cara!' >>> novavar = ['1kg de banana', '12 ovos', '1kg de farinha'] >>> novavar.append('fermento em pó') >>> print(novavar) ['1kg de banana', '12 ovos', '1kg de farinha', 'fermento em pó'] >>>
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question