Skip to content

Latest commit

 

History

History
72 lines (39 loc) · 2.47 KB

File metadata and controls

72 lines (39 loc) · 2.47 KB

Intermediate Challenges

Write a function

Write a function to add two numbers - and invoke it

Modify the function so that the expected argument is a tuple of two numbers

Create a list of such tuples e.g. coords = [ (3,4), (12, 13), ...]

Iterate through the list to generate a list of distances from the origin (use Pythagoras)

  1. use a for loop
  2. use a list comprehension
  3. (advanced) use map() and a lambda function

Chat with an AI model

Get a free OpenAI API key or Google Gemini Key. You may need to sign up.

Run the quickstart example to chat with the model.

Modify the quickstart so ask the model one of the Python questions in this exercise

Use the very popular VSCode editor with GitHub Codespaces

Set up a GitHub Codespaces session. This uses the VSCode editor.

Copy over some code from your Colab notebooks and run these in VSCode

Compare and contrast the two editors. Which do you prefer?

.py vs .ipynb

  1. What is the difference between .py and .ipynb files?
  2. Show how to run code in each type

Explore some famous packages

Python has many famous packages. Explore some of these.

For each package, write a tiny script that shows its capabilities.

Python Environments

Explain - What is a Python environment? Why are they used? What is pip?

Show the packages listed in your environment

Install a package not already in your environment e.g. cowsay. Test that it is has been installed, imported and is working properly?

Explore Hugging Face

Hugging Face is The GitHub for AI models. Go to the Hugging Face website and explore the models, spaces, tasks and datasets.

Look at the model of some models in particular

  • Microsoft Phi-4 here
  • a small Deepseek model here

Click on the "Use this model" button to see the Python code. Copy this and use to get a basic result.

Give a overview demo to the class.

Use an API

The Open Notify API server has an public API to list people in space here

Use this API to write the astronauts (first name, last name) in the ISS to a CSV or Excel file.