hands-on lab
Dynamic Programming with Python
Difficulty: Beginner
Duration: Up to 1 hour
Students: 1,928
Rating: 4.3/5
You can pause this lab for up to 1h
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.
Description
Lab Overview
Knowing how to write code in a Pythonic style is an important skill that should be mastered!
This lab is designed to show you how to exploit various Python language features to produce code that is considered to be Pythonic - being clear, concise, readable and maintainable.
- Exercise 1 - DynamicClasses: Complete the code required to dynamically create classes at runtime using the built-in type() function
- Exercise 2 - MonkeyPatching: Complete the code required to Monkey Patch a custom module - swapping out an existing function for an updated function at runtime
Note: Each exercise has a provided solution to consult with when needed.
Lab Objectives
Upon completion of this lab, you will be able to:
- Write Python code that can dynamically generate new classes at runtime programmatically
- Write Python code that can monkey patch existing Python code at runtime - thereby changing the behaviour of code
- Use the terminal to launch and debug Python scripts
You should:
- Be comfortable with using a browser-based IDE
Lab Environment
This lab will start with the following AWS resources provisioned automatically for you:
- A single EC2 instance, named ide.python.platform.instance, which will have a public IP address attached. This instance will host a web-based Python IDE (based on the Visual Code editor).
To achieve the lab end state, you will be walked through the process of:
- Using your local browser, access the web-based Python IDE served from the ide.python.platform.instance
- Completing the following lab exercises:
- Exercise 1 - DynamicClasses
- Exercise 2 - MonkeyPatching
Covered topics
Lab steps
Connecting to the Python IDE
Exercise 1 - Dynamic Classes
Exercise 2 - Monkey Patching