Module 1: Practice Sheet#
Objective#
Import the
sys
module.Print the version of Python being used.
Learn how to navigate a Python module documentation.
Instructions#
Import the
sys
module.Check the
sys
module documentation.Print the current Python version.
Print a statement combining a description and the Python version.
Note
The sys
module is a built-in tool in Python that lets you interact with the system your Python program is running on.
It gives you access to things like Pythonâs version, the command-line arguments used to run the program,
and the ability to control how your program runs.
N.B. built-in modules like sys
are part of the standard Python installation, so you donât need to install them separately. However, they need to be imported because Python doesnât automatically load every module into memory to save resources.
#1. Import sys module
### Your code here ###
#2. Try the function that gives you the current Python version.
### Your code here ###
#3. Print a statement combining a description and your Python version.
### Your code here ###
Hint 1
Check the sys
module documentation to find the function that gives you the Python version.
Hint 2
print()
statements allow you to combine descriptive strings with outputs, e.g. `print("your descriptive string ", sys function)`.
Solution
To print your Python version, you can use the following code:
import sys
sys.version
print('My Python version is ', sys.version)