Python Basics: Variables and Data Types

Getting Started with Python Basics 🚀 In the previous posts, we covered: 1. How to install Python on our systems 2. How to install the Playwright package in Python 3. How to create and download a project inside the IDE Now, we will move forward with the core learning. We will be covering the next topics in two sections: 1. Python Basics 2. Pytest Basics In this post, let’s get started with Python Basics. Creating Our First Python Program Let’s create our first Python file: FirstDemo.py To print anything to the console in Python, we use the print keyword. You can run the program by: Right-clicking on the file and selecting Run FirstDemo Or using the shortcut Ctrl + Shift + F10 Comments in Python When writing programs, it is always a good practice to add comments for better readability. In Python, comments start with the # character. Example Code print('hello') # here are the comments I have defined a = 3 print(a) Str = "Hello World" print(Str) b, c, d = 5, 6.4, "Great" Understanding Variables in Python Here, we declared a variable a and assigned the value 3. One key difference between Python and other programming languages is data type declaration. In Java, we must explicitly define the data type: int a = 3; In Python, we do not specify the data type. Python automatically determines the data type at runtime. Python does have data types, but they do not need to be explicitly mentioned while creating variables. Multiple Variable Assignment Python allows defining multiple variables in a single line, which makes the code clean and concise. Indentation Matters in Python Python is highly sensitive to code indentation. Indentation is not just formatting; it defines code structure. Editors like PyCharm enforce proper indentation by default and help ensure coding standards are followed. There are no semicolons at the end of statements in Python. This forms the foundation of Python basics before moving into pytest and Playwright automation. #Python #PythonBasics #LearningPython #TestAutomation #Playwright #Pytest #SDET #QAEngineering #AutomationTesting #SoftwareTesting #LearningJourney

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories