0% found this document useful (0 votes)
60 views

Python Features Overview

This document provides an overview of Python features, including: 1) Python basics like variables, logic/conditionals, lists, and functions. 2) Advanced features such as list comprehension, tuples, dictionaries, and collections. 3) Details about specific features - variables are not strongly typed, lists are powerful and can be accessed by index or sliced, dictionaries provide fast access using keys.

Uploaded by

sridevi kota
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Python Features Overview

This document provides an overview of Python features, including: 1) Python basics like variables, logic/conditionals, lists, and functions. 2) Advanced features such as list comprehension, tuples, dictionaries, and collections. 3) Details about specific features - variables are not strongly typed, lists are powerful and can be accessed by index or sliced, dictionaries provide fast access using keys.

Uploaded by

sridevi kota
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Python Features Overview

ADSA Advanced Workshops Fall 2018

bit.ly/CrashCourseADSA
bit.ly/ADSAPythonRefresh
Python Basics
- Variables
- Logic & Conditionals

Refresher -
-
Lists
Loops
- Functions

Notebook: https://goo.gl/gqLJCv
Variables
- Not strongly typed
- Built in Python functions that work across most
variable types
- Cast a variable to a different type
- Null/NaN values
- Swapping values between variables
Logic &
- Python uses the full words for most logical
operators

Conditionals -
-
False, True
and, or, not, in for logical comparisons
- !=, ==, <, >= for variable comparisons
- Full list can be found online
- Conditional statements perform the same as
most other programming languages
- if, elif, else
Lists
- Extremely powerful variable type in Python
- Declared with a comma separated sequence of
items surrounded by two brackets
- Access an item in the list by index
- Indices start from 0
- .append(), .insert(), .remove(), .index()
- List slicing
- List operators can be found online
Loops
- for and while loops as well as any nested
combination
- range([start], stop[, step]) (More info online)
- “for each” loops (More info online)
for <variable> in <sequence>:
- break, continue, and pass statements
Functions
- def and pass
- Standard parameters
- Default/optional parameters
Advanced Python
- List Comprehension
- Tuples

Features -
-
Dictionaries
Collections

Notebook: https://goo.gl/CtnVph
Python List
- Concise way to create lists
- [ expression for item in list if conditional ]

Comprehension - Many examples in the notebook


Tuples
- (X1, X2, X3, …, Xn)
- Like an immutable list
- len()
- Return multiple values in a function
Dictionaries
- List that is unordered, mutable, and indexed
- Elements are key : value pairs
- Fast access of elements when you know the key
- Iterate over items with for-each syntax
for key, value in mydict.items():
(key & value are just variable names in this
case)
- Get a list of just values/keys with values() or
keys()
- Common use is for string formatting
Collections
- High performance container datatypes as
alternatives to standard dict, list, set, & tuple
- namedtuple()
- Counter
- OrderedDict
- Read about others online

You might also like