DEV Community

Cover image for 5 Python DevOps Scripts: From Regex Extraction to Battle Report Automation
Labby for LabEx

Posted on

5 Python DevOps Scripts: From Regex Extraction to Battle Report Automation

Ready to level up your DevOps game? Modern software operations demand more than just knowing tools; you need the scripting power to handle data on the fly. We have handpicked five beginner-friendly Python challenges from our DevOps path that will sharpen your automation skills in just 5 minutes each. Let's dive into these practical exercises and start building your toolkit!

Extracting User Input Information

Extracting User Input Information

Difficulty: Beginner | Time: 5 minutes

In this challenge, we will implement a script that takes a string input from the user and extracts integers from it, treating any character other than 0-9 as a delimiter. The objective is to write code that can accurately identify and extract integers from user input, using regular expressions. The script should not contain any numbers and the expected output should display the extracted integers. Refer to the Requirements section for more details.

Practice on LabEx → | Tutorial →

Python File Type Counter

Python File Type Counter

Difficulty: Beginner | Time: 5 minutes

In this challenge we will work with the os module in Python to count the number of file types in a given directory. The aim is to write a script that takes user input for a file type and returns the number of files of that type in the directory. The script should return 0 if the file type does not exist. For this challenge we will use the file path /home/labex/project/file_type.py.

Practice on LabEx → | Tutorial →

Generating a Battle Report

Generating a Battle Report

Difficulty: Beginner | Time: 5 minutes

In this challenge, we will help the leader of the Galactic Empire's Clone Special Forces to create a battle report based on the battle situation of three enemy bases. The challenge involves processing data files for each base and sorting the battle information in descending order of value. The battle report should follow a specific template and include relevant details such as battle ID, value, total participants, injuries, deaths and fallen heroes.

Practice on LabEx → | Tutorial →

Extract Rightmost Digit in Python

Extract Rightmost Digit in Python

Difficulty: Beginner | Time: 5 minutes

In this challenge, we will define a function f(n, k) that returns the k-th digit from the right side of the integer n. The function should be completed in the given code template and the expected output should match the provided output. Remember to follow the requirements, such as not modifying the existing code and making sure the return type of the function is int.

Practice on LabEx → | Tutorial →

Extract Information From Parameters

Extract Information From Parameters

Difficulty: Beginner | Time: 5 minutes

In this challenge, we will implement a script that extracts numbers from a given text and calculates the average. The text will be passed as a parameter to the script, and the output will be the calculated average rounded to two decimal places. You need to write your code in ~/project/find_num.py and follow the requirements mentioned. There are also hints and an example provided for your reference. Good luck!

Practice on LabEx → | Tutorial →

These five labs are just the beginning of your DevOps journey. By completing these bite-sized challenges, you are building the muscle memory needed for real-world automation. Don't just read about DevOps—start coding it! Head over to the LabEx DevOps path and see how quickly you can master these essential skills.

Top comments (0)