UT Mathematics Python Seminar

The seminar will run in UH 4170 each Wednesday from 4 until our hearts desire. For now, please bring your own laptop if you wish to code along with us! See you there!

Date, Speaker, Topics

  • 9/20/17, Anthony Vasaturo
    1. Installing Python

      Head over to Python Downloads, scroll to the bottom, and download the 64-bit or 32-bit executable, depending on your PC. When the installation dialogue pops up, make sure to check the "Add to PATH" box.

    2. Installing PyCharm

      Check out PyCharm Download, and make sure to download the free Community Edition.

    3. Setting up Virtual Environments

      When in a PyCharm project, hit Ctrl+Alt+S to go to the settings for that project, click on "Project: Project_Title," then "Project Interpreter," then click the gear icon in the upper right corner, and select "Create VirtualEnv." Select whichever version of Python you would like as your base interpreter, then name the environment (be specific), and put it inside your main project folder. To add libraries to your environment, just click the "+" sign in the upper right corner of the interpreter, type in the name of the library you need, and click the "Install Package" button toward the bottom left of the screen.

    4. Beginner Learning and Reference Resources

      Check out the "Python Resources" page in the upper right corner of the banner!

    5. Some Basic Syntax

      Python is an object-oriented, general purpose language that uses functions, called "methods," and control structures to loop through and execute your code one line at a time.

  • 9/27/17, Anthony Vasaturo and Arianna Zikos
    1. Updates to Seminar Site

      Stay tuned for the appearance of more resources on the Python Resources page. Lectures will be updated with small summaries of each key point after they have occurred.

    2. Renaming PyCharm Projects

      In PyCharm, if you have a project open, the easiest way to rename it is to right click empty space in the project window located on the left side of the screen and select "Show in Explorer." This will take you to the project directory where you can rename the folder easily.

    3. Object Types

      Common object types include str (a string of characters or letters, entered in either single or double quotation marks), int (an integer), float (a non-integer number), bool (a True or False value for a given statement), None (an object can have a type of None), datetime (a date/time stamp in a variety of traditional formats), list (a list of objects), dict (a dictionary of keys and associated values), and many more! For a given object, apply the type() method to the object to get its type. Some objects can be transformed into an object of another type. For example, the string "2" can be transformed into the integer 2 by applying the int() method to "2" as follows: int("2") (this will return 2).

    4. Basic Variables

      Variables are objects with stored values that you will generally name yourself. For example, typing x = 4 in a Python shell or in a .py script will create a variable called x with a stored value of 4. Just make sure your variables don't start with numbers or special characters! See the documentation for more information.

    5. Indentation/Case Sensitivity in Python

      Python is a case-sensitive language. For example, creating a variable called num and attempting to call it later as Num is a no-no. Python also requires dependent code to be indented by 4 spaces (just hit Tab) below its parent code.

    6. And, Or, Not

      This is easy for mathematicians. For statements a and b, a and b will return True if both a and b are True. a or b will return True if either a or b or both are True. not a will return True if a is not True.

    7. Conditionals/Nested Conditionals

      Conditionals are truth tests. A block of indented, dependent code below the statement if a will run only if the condition a is met. elif b will be checked only if preceding dependent if statements did not run, and will run themselves only if condition b is met. Else statements will be checked only if all dependent preceding if and elif statements did not run, and will always run themselves if they are checked because they represent all other cases not met by preceding conditionals.

    8. Compound Booleans

      More to come...

  • 10/4/17, Anthony Vasaturo and Arianna Zikos
    1. Nested Conditionals

      There is nothing stopping you from nesting if, for, while statements inside of each other. Just make sure that you indent each successive conditional with 4 spaces, or press Tab!

    2. Compound Booleans

      And, Or, Not statements can be compounded so that multiple conditions are checked at once. For example, if you want conditions X, Y and Z to hold prior to running a block of code, you would type if X and Y and Z: followed by your code typed as an indented block.

    3. More on Loops and Strings

      You can access portions of strings through which you would like to iterate using colon notation. For example, to iterate through every other character in the string s = 'Anthony' beginning 'A' and ending at 'o', I would type for letter in s[0:5:2]:, where the numbers 0, 4, and 2 represent the first index of s I would like to print, the index after the last index I would like to print, and the iteration increment, respectively.

    4. Functions and Scope

      Syntax to create a function is as follows: def function_name(parameters):. Once the function name and any parameters are specified, indent the block of code you would like the function to execute immediately beneath the function declaration.

    5. Basic Recursion

      More on this later...

    6. Tuples, Lists, Mutability, Aliasing, and Cloning

      Tuples are immutable objects, meaning they cannot be altered via methodology. The syntax is as follows: (item1, item2, ...). The parentheses are often not needed. Lists are mutable, and come with a host of built-in methods. See Data Structures for more information.

  • 10/11/17, Anthony Vasaturo, Arianna Zikos, and Jacob Noon
    1. List Methods

      See "Tuples, Lists, Mutability, Aliasing, and Cloning" from last week's lecture.

    2. Bubble Sort

      Finding efficient ways to sort a list in Python is a challenging problem. We discussed an elementary method of sorting lists called Bubble Sort. Python's built-in .sort() list method uses a powerful algorithm called Timsort.