#!/bin/bash # Update the package list sudo apt-get update # Install the software-properties-common package sudo apt-get install software-properties-common # Add the deadsnakes PPA to the sources list sudo add-apt-repository ppa:deadsnakes/ppa # Update the package list again sudo apt-get update # Check the latest version of Python 3 available latest_version=$(apt-cache madison python3 | awk '{print $3}' | grep "^3\." | sort -V | tail -1) # Install the latest version of Python 3 sudo apt-get install -y python3=$latest_version # Verify the installation python3 --version which python3