This lesson is in the early stages of development (Alpha version)

Intermediate Python: How to use the lesson template

Notes on how to use this lesson template

See the Lesson Example and The Carpentries Curriculum Development Handbook for full details. Below should be all the things you need to know right now…

Creating pages

---
title: The Title of the Section
---
---
title: Syntax Elements & Powerful Functions
teaching: 20
exercises: 10
questions:
- "What elements of Python syntax might I see in other people's code?"
- "How can I use these additional features of Python to take my code to the next level?"
- "What built-in functions and standard library modules are recommended to improve my code?"
objectives:
- "write comprehensions to improve code readability and efficiency."
- "call functions designed to make common tasks easier and faster."
- "recognise all elements of modern Python syntax and explain their purpose."
keypoints:
- "Use comprehensions to efficiently create new iterables with fewer lines of code."
- "Sets can be extremely useful when comparing collections of objects, and create significantly speed up your code."
- "The `itertools` module includes many helpful functions for working with iterables."
- "A decorator is a function that does something to the output of another function."
---

Code blocks

code snippets written like this

~~~
print(weight_kg)
~~~
{: .language-python}
~~~
60.0
~~~
{: .output}

will produce formatted blocks like this:

print(weight_kg)
60.0

Special blockquotes

A callout block written like this

> ## Callout block example
>
> Write callout blocks as blockquotes,
> with a styling tag (techincal term is a _class identifier_) at the end.
>
> ~~~
> # you can still include code blocks in the callout
> weight_lb = 2.2 * weight_kg
> print(weight_kg_text, weight_kg, 'and in pounds:', weight_lb)
> ~~~
> {: .language-python}
>
> Use callouts for asides and comments -
> anything that provides additional detail to the core of your material
{: .callout}

will be rendered like this:

Callout block example

Write callout blocks as blockquotes, with a styling tag (techincal term is a class identifier) at the end.

# you can still include code blocks in the callout
weight_lb = 2.2 * weight_kg
print(weight_kg_text, weight_kg, 'and in pounds:', weight_lb)

Use callouts for asides and comments - anything that provides additional detail to the core of your material

Similarly, exercises written like this

> ## Sorting Out References
>
> What does the following program print out?
>
> ~~~
> first, second = 'Grace', 'Hopper'
> third, fourth = second, first
> print(third, fourth)
> ~~~
> {: .language-python}
>
> > ## Solution
> >
> > This text will only be visible if the solution is expanded
> > ~~~
> > Hopper Grace
> > ~~~
> > {: .output}
> {: .solution}
{: .challenge}

will be rendered like this (note the expandable box containing the solution):

Sorting Out References

What does the following program print out?

first, second = 'Grace', 'Hopper'
third, fourth = second, first
print(third, fourth)

Solution

This text will only be visible if the solution is expanded

Hopper Grace

{% include links.md %}