Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> True True >>> False False >>> a = 'cat' >>> len(a) > 5 || a.startswith('c') SyntaxError: invalid syntax >>> len(a) > 5 or a.startswith('c') True >>> if True: print("The condition is true.") x = 5 print("The value of x is:", x) The condition is true. The value of x is: 5 >>> x 5 >>> value = "This is a sentence." >>> value.find('T') 0 >>> value.find('T') == 0 or value.find('A') == 0 or value.find('B') == 0 True >>> value[0] 'T' >>> value[1] 'h' >>> value[0:5] 'This ' >>> value[0] 'T' >>> 'A' <= value[0] and value[0] <= 'Z' True >>> value = ' This is a sentence.' >>> value[0] ' ' >>> 'A' <= value[0] and value[0] <= 'Z' False >>> value ' This is a sentence.' >>> value.strip() 'This is a sentence.' >>> 'A' <= value.strip()[0] and value.strip()[0] <= 'Z' True >>> value ' This is a sentence.' >>> value ' This is a sentence.' >>> value.upper() ' THIS IS A SENTENCE.' >>> value ' This is a sentence.' >>> 'A' <= value.strip()[0] and value.strip()[0] <= 'Z' True >>> value.strip()[0] 'T' >>> value.strip()[0].isupper() True >>> '1234'.isupper() False >>> 'ABCD'.isupper() True >>> 'ABcd'.isupper() False >>> 'AB12'.isupper() True >>> value.strip()[0].isupper() True >>> import string >>> string.punctuation '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' >>> ================================ RESTART ================================ >>> Enter string: This is a sentence. This starts with a capital letter, so it might be a sentence. This ends with a punctuation mark. >>> ================================ RESTART ================================ >>> Enter string: dzfgjlkaer >>> x = 'cat' >>> if len(x) >5 or x.startswith('c'): print("This is at least 6 characters or starts with a c.') SyntaxError: EOL while scanning string literal >>> if len(x) >5 or x.startswith('c'): print("This is at least 6 characters or starts with a c.") else: print("That was not the case.") This is at least 6 characters or starts with a c. >>> if True: print("true") else: SyntaxError: invalid syntax >>> ================================ RESTART ================================ >>> Enter string: av r This string is probably not a sentence. This will always execute >>> ================================ RESTART ================================ >>> Enter string: faZS This string is probably not a sentence. This will always execute >>> ================================ RESTART ================================ >>> Enter string: Cat. This string might be a sentence. >>> ================================ RESTART ================================ >>> Enter string: This is a sentence. This string might be a sentence. This will always execute >>> ================================ RESTART ================================ >>> Enter string: >>> ================================ RESTART ================================ >>> Enter string: This is a sentence This string is probably not a sentence. It does not end with a valid punctuation mark. This will always execute >>> ================================ RESTART ================================ >>> Do you want fries with your order? yes What size? (small, medium, or large) small >>> total 2.0 >>> ================================ RESTART ================================ >>> Do you want fries with your order? yes What size? (small, medium, or large) medium >>> total 2.25 >>> ================================ RESTART ================================ >>> Do you want fries with your order? yes What size? (small, medium, or large) aserfar >>> ================================ RESTART ================================ >>> Do you want fries with your order? yes What size? (small, medium, or large) ftghx >>> ================================ RESTART ================================ >>> Do you want fries with your order? no Invalid size. >>> ================================ RESTART ================================ >>> Do you want fries with your order? y What size? (small, medium, or large) medium >>> total 1.5 >>> ================================ RESTART ================================ >>> Do you want fries with your order? medium medium >>> val = input("Enter a number: ") Enter a number: 15 >>> val '15' >>> type(val) >>> int(val) 15 >>> isinstance(val, str) True >>> isinstance(val, int) False >>>