Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ===== Overview ===== First pass at Python course topics. Links: ... coming ... ===== Internal links ===== * [[Python_file_hierarchy]] ===== Packages ===== * ''python3'' (Python 3.7) <code> $ python3 -V Python 3.7.4 $ </code> ===== Online tutorial ===== ==== 3 ==== * string operations * string slices ==== 4 ==== * "else" clause on loop constructs * range() function is an "iterable" * keyword arguments * lambda expressions * docstrings * function annotation(???) ==== 5 Data structures ==== * lists * "import collections" (deque) * list comprehensions * set * dictionary * key can be any immutable type * "list(d)" returns list of keys * "enumerate()" routine for any sequence * "zip()" to iterate over two sequences simultaneously ===== TOPICS ===== * string method join() * data types, numbers, literals * "_" as last value interactively * single and double quoted strings identical effectively * raw strings * "iterable" objects ("for" is an "iterator") * list(range(1,10)) * tuple(range(1,10)) * loops and trailing "else" construct ===== STUFF ===== * ''%%>>> quit()%%'' * PEP-8 * function annotations ===== Basics ===== ==== Arguments ==== <code> import sys print(sys.argv[0]) </code> ==== Printing ==== <code> >>> print("hi") >>> print("I am", age, "years old.") >>> print(f"I am {age} years old.") (format string) >>> hilarious = False >>> joke_evaluation = "Isn't that joke so funny?! {}" >>> print(joke_evaluation.format(hilarious)) >>> print("Isn't that funny? {}".format(hilarious)) >>> print(end1 + end2 + end3 + end4 + end5 + end6, end=' ') >>> print(end7 + end8 + end9 + end10 + end11 + end12) >>> formatter = "{} {} {} {}" >>> print(formatter.format(1, 2, 3, 4)) >>> print(formatter.format("one", "two", "three", "four")) </code> ==== Strings ==== Raw strings: r"blah blah" <code> print("""\ Usage: thingy [OPTIONS] -h Display this usage message -H hostname Hostname to connect to """) </code> python.txt Last modified: 2020/06/17 14:40by rpjday