Playwright + Python · Lesson 1 of 37

0/37 done

Module 1: Python Basics

1. Python Syntax & Variables for Test Automation

14 minlesson

Your task

Implement format_test_status(passed_count, total_count):

  1. If total_count == 0, return "NO_TESTS".
  2. If passed_count == total_count, return "ALL_PASSED".
  3. Otherwise return f"{passed_count}/{total_count} PASSED".

Write it in the editor, then press Check answer (Ctrl + Enter).

Python Variables & Data Types

Python is dynamically typed and indentation-sensitive. Variables are assigned with =.

python
# Test configuration variables:
base_url = "https://targetqa.com"
timeout_seconds = 30
implicit_wait = 2.5
is_headless = True
auth_token = None

# Arithmetic & comparison operators:
attempts = 0
attempts += 1
is_ready = attempts >= 3 and is_headless

Key Takeaways & Walkthrough Summary

Welcome to Playwright with Python! Python is renowned for its clean, readable syntax and immense automation ecosystem. In this lesson, we cover variables, primitive data types including integers, floats, strings, booleans, and None, along with comparison and logical operators. Let's get started!

Part of the Playwright + Python course (Playwright with Python). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

What is 'None' in Python?

None represents the absence of a value or a null object, equivalent to null in Java and JavaScript.

Ready? Solve the task in the editor

Use Check answer to mark it complete. Hints are there if you need them.

Python
Skip