Programming

Python 3.8 Playground

Get access to the Python 3.8 playground in 1 click

Quickly jump in to test, simulate and practice your Python coding skills in this playground straight to your browser!

Playground Features

  • Equipped with VS Code Integrated Development Environment (IDE) complete with Terminal to run your Python code
  • Python interpreter version: Python 3.8.0

What is Python?

Python is the most versatile programming language to date. It covers the most use cases for modern technologies today such as scripting, web development, AI and machine learning, data analytics, QA automated testing, and more! That’s why it’s very important for DevOps engineers to learn Python since they will most likely work with these different types of technologies in the industry. 

DevOps practices, which deal with a lot of automation, often require you to write automation scripts. Python adds more power and features to your scripts that otherwise would be limited with just plain Bash scripts. Some of the tools that DevOps uses are usually written in Python, so having the knowledge will certainly become handy when troubleshooting tough issues.

Python also does exceptionally well with web development, as you can build complete frontend and backend web applications with the help of web frameworks such as Django and Flask. You can create your own consoles or custom dashboards to help you manage, monitor, and develop reporting mechanisms that make your life easier as a DevOps engineer.

Python is also great because it’s very easy to learn. If you’re new, no problem! The Python syntax is straightforward, clean, and super readable, making it easier to understand even with the most complex implementations. 

What’s new in Python version 3.8?

1. New Walrus Operator - allows you to assign variables inside an expression

# Printing a variable involves assignment then a separate line to print
print_me = "Hello World"
print(print_me)

# Now, you can now do something like this. Cleaner and less code right?
print(print_me_too := "Hello World")

Output: 

Hello World
Hello World

2. F-Strings are now supported - F-strings allow you to print both variables and values for debugging purposes.

print_me = "Hello World"
print(f"Hello, {print_me=}")

Output:

Hello, print_me='Hello World'

3. Positional-only parameters using “/” - In Python, functions support both positional and keyword parameters. The “/” gives you a clear identifier of the positional-only parameters.

# We put the slash in the 3rd parameter of the function
# This means a and b should only be positional parameters
def test (a, b, /, c, d):
    print(a, b, c, d)
   
test(1, 2, c=3, d=4)

Output:

1 2 3 4

If we set a and b as keyword parameters we get an error

def test (a, b, /, c, d):
    print(a, b, c, d)

test(a="a", b="b", c=3, d=4)

Output:

TypeError: test() got some positional-only arguments passed as keyword
arguments: 'a, b'