Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> x = "This is a string." >>> w = "Here is one more string." >>> x + w 'This is a string.Here is one more string.' >>> x 'This is a string.' >>> w 'Here is one more string.' >>> z = x + w >>> z 'This is a string.Here is one more string.' >>> 3*w 'Here is one more string.Here is one more string.Here is one more string.' >>> z*2 'This is a string.Here is one more string.This is a string.Here is one more string.' >>> z*1.4 Traceback (most recent call last): File "", line 1, in z*1.4 TypeError: can't multiply sequence by non-int of type 'float' >>> x = input("Enter something.") SyntaxError: unexpected indent >>> x = input("Enter something.") Enter something.123456 >>> x '123456' >>> x '123456' >>> y Traceback (most recent call last): File "", line 1, in y NameError: name 'y' is not defined >>> w 'Here is one more string.' >>> z 'This is a string.Here is one more string.' >>> x[0] '1' >>> z[0] 'T' >>> z[3] 's' >>> z[4] ' ' >>> z[3+7] 's' >>> x[0] '1' >>> x[1] '2' >>> x[4] '5' >>> x[5] '6' >>> x[6] Traceback (most recent call last): File "", line 1, in x[6] IndexError: string index out of range >>> s = "a short string" >>> s[-1] 'g' >>> s[-2] 'n' >>> s[-5] 't' >>> s[3:8] 'hort ' >>> s[8:14] 'string' >>> s[8:13] 'strin' >>> s[8:] 'string' >>> for k in len(s): print(s[:k] + s[k+1:]) Traceback (most recent call last): File "", line 1, in for k in len(s): TypeError: 'int' object is not iterable >>> for k in range(len(s)): print(s[:k] + s[k+1:]) short string ashort string a hort string a sort string a shrt string a shot string a shor string a shortstring a short tring a short sring a short sting a short strng a short strig a short strin >>> s 'a short string' >>> x = 'string' >>> for k in range(len(x)): print(s[:k]+s[k+1:]) short string ashort string a hort string a sort string a shrt string a shot string >>> for k in range(len(x)): print(x[:k] + x[k+1:]) tring sring sting strng strig strin >>> x 'string' >>> len(x) 6 >>> len(s) 14 >>> w 'Here is one more string.' >>> len(w) 24 >>> len(z) 41 >>> for k in range(len(x)): print(x[k]) s t r i n g >>> x[2:] 'ring' >>> x[:3] 'str' >>> for k in range(len(x)): print(x[k], end = ' ') s t r i n g >>> for c in x: print(c) s t r i n g >>> range(x) Traceback (most recent call last): File "", line 1, in range(x) TypeError: 'str' object cannot be interpreted as an integer >>> list(range(10, -2, -1)) [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1] >>> list(range(7)) [0, 1, 2, 3, 4, 5, 6] >>> list(range(4, 18)) [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] >>> list(range(4, 18, 3)) [4, 7, 10, 13, 16] >>> list(range(3, -5, -1)) [3, 2, 1, 0, -1, -2, -3, -4] >>> list(range(-1, len(x), -1)) [] >>> len(x) 6 >>> w 'Here is one more string.' >>> s 'a short string' >>> list(range(-1, len(x), -1)) [] >>> list(range(-1, len(s), -1)) [] >>> len(s) 14 >>> list(range(-1, -len(s), -1)) [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13] >>> for k in range(-1, -len(s), -1): print(s[k]) g n i r t s t r o h s >>> for k in range(-1, -(len(s)+1), -1): print(s[k]) g n i r t s t r o h s a >>> y= [0, 35.23, "some words", -5, 'v'] >>> y [0, 35.23, 'some words', -5, 'v'] >>> len(y) 5 >>> y[0] 0 >>> y[2] 'some words' >>> y[4] 'v' >>> y[3] -5 >>> type(y) >>> type(y[3]) >>> type(y[4]) >>> y[1:3] [35.23, 'some words'] >>> y + y [0, 35.23, 'some words', -5, 'v', 0, 35.23, 'some words', -5, 'v'] >>> x =[1, 4, 'acd'] >>> y +x [0, 35.23, 'some words', -5, 'v', 1, 4, 'acd'] >>> 3*x [1, 4, 'acd', 1, 4, 'acd', 1, 4, 'acd'] >>> for each in y: print(each, type(each)) 0 35.23 some words -5 v >>> ord('c') 99 >>> ord('x') 120 >>> ord('^') 94 >>> ord(4) Traceback (most recent call last): File "", line 1, in ord(4) TypeError: ord() expected string of length 1, but int found >>> chr(45) '-' >>> chr(101) 'e' >>> chr(97) 'a' >>> for i in range(97, 110): print(chr(i)) a b c d e f g h i j k l m >>> for ch in w: print(ord(w), ' ') Traceback (most recent call last): File "", line 2, in print(ord(w), ' ') TypeError: ord() expected a character, but string of length 24 found >>> >>> for ch in w: print(ord(ch)) 72 101 114 101 32 105 115 32 111 110 101 32 109 111 114 101 32 115 116 114 105 110 103 46 >>> w 'Here is one more string.' >>>