Table of Contents INTRODUCTION

Table of Contents INTRODUCTION

PYTHON PROGRAMMING Notes by Michael Brothers http://titaniumventures.net/library/ Table of Contents INTRODUCTION ...................................................................................................................................................................... 5 What is Python? ................................................................................................................................................................. 5 Ways to Code Python ......................................................................................................................................................... 5 Using Anaconda .................................................................................................................................................................. 5 Using Jupyter Notebooks ................................................................................................................................................... 5 Python 2 vs Python 3 .......................................................................................................................................................... 5 PEP 8 -- Style Guide for Python Code................................................................................................................................. 5 Using this guide: ................................................................................................................................................................. 5 PYTHON PROGRAMMING ...................................................................................................................................................... 6 Variables ............................................................................................................................................................................. 6 Multiple Declaration .......................................................................................................................................................... 6 Multiple Assignment .......................................................................................................................................................... 6 Data Types .......................................................................................................................................................................... 6 Operators ............................................................................................................................................................................ 6 Comparison Operators: ...................................................................................................................................................... 6 Chained Comparison Operators: ....................................................................................................................................... 6 Strings: ................................................................................................................................................................................ 7 Lists: .................................................................................................................................................................................... 7 Tuples: ................................................................................................................................................................................. 7 Dictionaries: ........................................................................................................................................................................ 7 Sets:..................................................................................................................................................................................... 7 Comments:.......................................................................................................................................................................... 7 WORKING WITH STRINGS ...................................................................................................................................................... 8 Built-in String Functions: .................................................................................................................................................... 8 Built-in String Methods: ..................................................................................................................................................... 8 Splitting Strings: ................................................................................................................................................................. 8 Joining Strings: .................................................................................................................................................................... 8 Turning Objects Into Strings ............................................................................................................................................... 8 String formatting with formatted string literals (f-strings) ............................................................................................... 9 String Formatting with .format() ..................................................................................................................................... 10 String Formatting with Placeholders: .............................................................................................................................. 11 Escape Characters: ........................................................................................................................................................... 11 WORKING WITH LISTS: ......................................................................................................................................................... 12 Built-in List Functions: ...................................................................................................................................................... 12 Built-in List Methods: ....................................................................................................................................................... 12 Adding & Removing List Items ......................................................................................................................................... 12 List Index Method ............................................................................................................................................................. 12 Sorting Lists....................................................................................................................................................................... 13 Making a List of Lists: ....................................................................................................................................................... 13 LIST COMPREHENSIONS ....................................................................................................................................................... 14 WORKING WITH TUPLES ...................................................................................................................................................... 15 WORKING WITH DICTIONARIES ........................................................................................................................................... 15 Dictionary Comprehensions: ............................................................................................................................................ 15 WORKING WITH SETS: .......................................................................................................................................................... 16 Set Operators .................................................................................................................................................................... 16 1 REV 1020 Built-in Set Methods ........................................................................................................................................................ 16 Frozensets ......................................................................................................................................................................... 16 RANGE ................................................................................................................................................................................... 16 CONDITIONAL STATEMENTS & LOOPS ................................................................................................................................ 17 If / Elif / Else statements: ................................................................................................................................................. 17 For Loops .......................................................................................................................................................................... 17 While Loops ...................................................................................................................................................................... 17 Nested Loops .................................................................................................................................................................... 17 Loop Control Statements (Break, Continue, Pass

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    56 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us