Introduction to Python
In this workshop, we will cover the following:
- Learn the syntax of Python 3
- Learn basic programming concepts and data structures
- Download Anaconda https://www.anaconda.com/download/
- Please ensure that you have admin priviledges on your laptop to install and use anaconda successfully
- Download the Jupyter notebook file in this repository
- Run Jupyter notebook (from the start menu or from anaconda navigator) and 'upload' the jupyter notebook file, or navigate to the file location of the jupyter notebook file that you have downloaded.
- If you have any issue with installing the above, try:
- https://docs.anaconda.com/anaconda/install/#detailed-installation-information has detailed installation instructions.
- Try googling your issue directly
- Have a look through the help at https://github.com/ContinuumIO/anaconda-issues/issues.
- Shoot us an email if you're still stuck.
- As a group we go through some personal introductions, and then discussions about coding and python.
- Programming fosters creativity, reasoning, logic and problem solving. Learning to code can prompt you to think differently and attack problems from different angles.
- Python is used broadly in education, science, and industry.
- Anaconda and jupyter notebook is a distribution of python that very easy to install.
- Open Jupyter notebook
- Create a blank jupyter notebook or use the one we provided
- Click to edit a cell and make sure it is of type
code
notmarkdown
- type
print("Hello World!")
- Click the play button or run the code with ctrl+enter
- You have just written your first program!
-
As a group, we move through the contents inside of the Jupyter notebook file.
- The Jupyter notebook contains explanations of each and code-a-long exercises.
- Jupyter notebook is handy because you can write and run code right inside of the Jupyter notebook file.
- While Jupyter notebook is really very intuitive and easy to use, if you get stuck, or wish to read some more detailed documentation and information about jupyter notebook, see https://jupyter-notebook.readthedocs.io/en/stable/notebook.html
-
Topics introduced are:
- Values, Variables, and Types
- We introduce variables, and data types. Variables hold data, and allow you to easily manipulate the data inside of the variable. Data typing is another fundamental concept that we introduce. Types tell the computer what operations can be performed on the data.
- More reading on data types: https://en.wikiversity.org/wiki/Python_Concepts/Basic_data_types
- Operators
- Python has some in built operators which allow you to perform basic math on integers, and concatenate strings together
- e.g
5 + 5 = 10
and'5' + '5' = '55'
- if the data type is integer or float, 5 and 5 are added to equal ten. Quotation indicates to the computer that '5' is a string, and the + operator concatenates the two
5
's together. - More reading on operators: https://www.tutorialspoint.com/python/python_basic_operators.htm
- Basic python operators: https://www.tutorialspoint.com/python/python_basic_operators.htm
- Functions
- Functions allow you to name chunks of code, reuse them repeatedly, and easily use code that other people have written.
- Functions: https://en.wikiversity.org/wiki/Python_Programming/Functions
- Objects and Methods
- We provide a high level explanation of objects and methods.
- Lists
- Lists are a way to store an array of variables inside of another variable. We can do lots of cool things with lists.
cool_list = [1,2,3,4,5]
print(cool_list[2:])
- https://www.tutorialspoint.com/python/python_lists.htm
- Input and Output
- You can ask the user for information to use inside of your program!
name = input()
- print(name)
- Control Structures
- If statements
- If statements run a block of code if they are true.
- `if (name == 'Codelikeagirl'):
print('cool!
)
- https://en.wikiversity.org/wiki/Python_Concepts/If_Statement
- Loops
- Loops let you run some code over and over and over and over again!
- https://en.wikiversity.org/wiki/Python_Programming/Loops
- If statements
- Values, Variables, and Types
-
Documentation/further reading:
- Python documentation: https://docs.python.org/3/
- Python 3 tutorial on tutorials point (Good for quick reference): https://www.tutorialspoint.com/python3/index.htm
- In this workshop, we covered introductory coding concepts taught through hands-on code a long activities using Jupyter Notebook, guided by the lead instructor of the workshop.
- Reflection questions to reinforce what they have learnt (refer to the curriculum template for more explanation)
- Further reading and things to do for attendees:
- Code Academy: https://www.codecademy.com/catalog/subject/programming
- PyLadies - run in many locations all over the world: http://www.pyladies.com/locations/
- Talk Python to me: (A Podcast) https://talkpython.fm/
- Reddit has a lot of resources:
- Very comprehensive guide from r/learnprogramming https://www.reddit.com/r/learnprogramming/wiki/faq#wiki_getting_started
- A guide that gives some structure on what to do if you're trying to become job-ready: https://github.com/P1xt/p1xt-guides/blob/master/job-ready-javascript-edition-2.0.md
- If you like learning from books, try: Introduction to Computing Using Python: An Application Development Focus, 2nd Edition ISBN: 978-1-118-89094-3
- Introduction to Computer Science from EdX (if you're super keen) : https://www.edx.org/course/cs50s-introduction-computer-science-harvardx-cs50x