Instructor: Michelle Wang
Outline
This lecture is designed to get students up and running with Python. It is expected that Python 3 (preferably 3.8 or later) is installed, and that the students have some basic previous experience in a scripting language.
It will guide students through the fundamental syntax, concepts, and data structures required to code in Python 3.
Topics include:
- running your code,
 - commenting,
 - variables,
 - arithmetic,
 - logic,
 - strings, lists, tuples, dictionaries,
 - functions,
 - libraries,
 - if statements,
 - loops,
 - exceptions,
 - and classes.
 
Questions you will be able to answer after taking this module
- 
    
How does the use of a
breakstatement alter the flow of a loop in Python? - 
    
What happens if you attempt to append new elements to a Tuple?
 - 
    
Without running the code on your machine, what is the printed output when the following code is run?
my_dictionary = {"a" : 1, "b" : {"c" : {"d" : [4,5,6,4]}}, "c" : [1,2,3]} x = my_dictionary["b"]["c"]["d"].append(my_dictionary["c"][-3]) print(my_dictionary.values())[1, {'c': {'d': [4, 5, 6, 4]}}, [1, 2, 3]][1, {'c': {'d': [4, 5, 6, 4, 1]}}, [1, 2, 3]][1, [4,5,6,4,1], [1,2,3]][1, [4,5,6,4], [1,2,3]]
 - 
    
Without running the code on your machine, which string is returned by
my_functionwhen called with the specified parameters?def my_function(x, y, z): result = "" if len(z) <= 6 and len(z) > 2: result = z[-2] + y else: result = x + y return x + x + result my_function("111", "abc", "0100")1111110abc0abc111111111111bca01111111110
 
Material
Resources
Extras
- 
    
The good research handbook is for grad students, postdocs and PIs who do a lot of programming as part of their research. It will teach you, in a practical manner, how to organize your code so that it is easy to understand and works reliably.
 - 
    
Sourcery.ai for live code reviews to improve your Python code
 - 
    
An unbiased evaluation of Python environment management and packaging tools
 
Podcasts
- Python bytes for quick regular updates in whatβs new in the world of Python
 - Talk Python to me
 - Real Python with many courses and a podcast