Skip to main content

Python Basics for Testers: Variables, Data Types & Print Statements

 

πŸ“¦ 1. What is a Variable?

Think of a variable as a box that stores something for later use.

In Python, you don’t need to say what kind of data will go into the box. Just give it a name and assign a value.

πŸ”§ Syntax:

name = "Alice"
age = 30

🧠 Explanation:

  • name is a variable that holds the text "Alice".

  • age is a variable that holds the number 30.

✅ Rules for Variable Names:

  • Must start with a letter or underscore (_)

  • Can contain letters, numbers, and underscores

  • Case-sensitive (Name and name are different)

  • Avoid using Python keywords (like for, if, print, etc.)


πŸ”’ 2. Data Types in Python

A data type tells Python what kind of value you're working with.

Here are the most common ones testers need:

πŸ”€ a. String (str)

A string is a sequence of characters, like text.

city = "Tallinn"

Anything inside quotes (" " or ' ') is a string.

➕ You can join strings:

first = "Quality"
second = "Assurance"
result = first + " " + second
print(result)  # Output: Quality Assurance

πŸ”’ b. Integer (int)

An integer is a whole number — no decimals.

bugs_found = 5

πŸ”£ c. Float (float)

A float is a number with a decimal point.

bug_rate = 2.5

❓ d. Boolean (bool)

A boolean is either True or False.

is_test_passed = True

Useful for conditions like “Did this test pass?”


πŸ—ƒ️ e. List (list)

A list stores multiple values in one variable.

test_cases = ["Login Test", "Signup Test", "Search Test"]
print(test_cases[0])  # Output: Login Test

Lists start at index 0. You can store strings, numbers, or even other lists!


πŸ—‚️ f. Dictionary (dict)

A dictionary stores data as key-value pairs.

bug = {
    "id": 101,
    "title": "Login fails",
    "status": "Open"
}
print(bug["title"])  # Output: Login fails

Perfect for storing bug data or test case info.


πŸ–¨️ 3. Using Print Statements

The print() function shows output on the screen.

Example:

print("Testing is fun!")

Output:

Testing is fun!

πŸ”„ Print Variables

You can print variables directly:

name = "Alice"
print(name)

Output:

Alice

πŸ’¬ Combine Text and Variables

Method 1: Comma , (most beginner-friendly)

tester = "Bob"
print("Tested by:", tester)

Output:

Tested by: Bob

Method 2: f-Strings (modern and clean)

age = 28
print(f"The tester is {age} years old.")

Output:

The tester is 28 years old.

✅ Why Testers Should Learn This?

Even if you're not writing full Python programs, knowing these basics helps you:

  • Read automation test scripts

  • Debug test failures

  • Modify test data

  • Build test input/output quickly


πŸ§ͺ Small Practice Project: Bug Summary

Let’s combine what you learned into a tiny program.

πŸ› ️ Code:

bug_id = 101
bug_title = "Signup button not working"
severity = "High"
is_reproducible = True

print("Bug Report")
print("-----------")
print("ID:", bug_id)
print("Title:", bug_title)
print("Severity:", severity)
print("Reproducible?", is_reproducible)

πŸ–₯️ Output:

Bug Report
-----------
ID: 101
Title: Signup button not working
Severity: High
Reproducible? True

You just printed a bug report using variables, different data types, and print statements!


πŸ€” Quick Recap

Concept Example Description
Variable name = "Bob" Stores a value
String (str) "Login Failed" Text data
Integer (int) 10 Whole number
Float (float) 9.5 Decimal number
Boolean (bool) True, False Yes/No or On/Off
List (list) ["TC1", "TC2"] Group of values
Dictionary (dict) {"id": 1, "status": "Open"} Key-value pair structure
Print print("Hello!") Shows output

πŸŽ“ Final Thoughts

If you're starting your QA journey, Python is your friend. It's clean, beginner-friendly, and widely used in testing tools.

Today, you learned how to:

  • Store data in variables

  • Use common data types

  • Print anything to the screen

Next steps? Learn conditions, loops, and functions — they’ll help you write smarter test scripts or explore automation.


πŸ’‘ Bonus Tip for Testers

You can use Python to:

  • Generate random test data

  • Compare expected vs actual results

  • Read/write files (like test reports or logs)

  • Connect with tools like Selenium or APIs


That’s it for today’s Python basics! Start small, practice daily, and you’ll become comfortable with Python in no time.


Comments

Popular posts from this blog

30 Manual Testing interview questions from glass door

Here are 30 manual testing interview questions commonly encountered in interviews, compiled from various sources including Glassdoor: What is the difference between Quality Assurance (QA), Quality Control (QC), and Software Testing? QA focuses on improving the processes to deliver Quality Products. QC involves the activities that ensure the verification of a developed product. Software Testing is the process of evaluating a system to identify any gaps, errors, or missing requirements. Can you explain the Software Testing Life Cycle (STLC)? The STLC includes phases such as Requirement Analysis, Test Planning, Test Case Development, Environment Setup, Test Execution, and Test Closure. What is the difference between Smoke Testing and Sanity Testing? Smoke Testing is a preliminary test to check the basic functionality of the application. Sanity Testing is a subset of regression testing to verify that a specific section of the application is still worki...

Part 1-Interview questions for Manual testing

1. What is Software Testing? Answer: Software testing is the process of evaluating a software application to identify any discrepancies between expected and actual outcomes, ensuring the product is defect-free and meets user requirements. ​ GUVI 2. What are the different types of Software Testing? Answer: The main types include: ​ Software Testing Material +1 LinkedIn +1 Functional Testing: Validates the software against functional requirements. ​ Non-Functional Testing: Assesses aspects like performance, usability, and reliability. ​ Manual Testing: Test cases are executed manually without automation tools. ​ Software Testing Material +2 LinkedIn +2 Katalon Test Automation +2 Automation Testing: Utilizes scripts and tools to perform tests automatically. ​ 3. What is the difference between Verification and Validation? Answer: Verification: Ensures the product is designed correctly, focusing on processes and methodologies. ​ Validation: Ensures the bui...

1000 Interview questions part 1

Test Case Design – Interview Questions & Answers (1–50) 1. What is a test case? A test case is a set of actions executed to verify a particular feature or functionality of your application. 2. What are the components of a test case? Test case ID, Description, Preconditions, Steps, Test Data, Expected Result, Actual Result, Status, Comments. 3. What is test case design? It's the process of creating a set of inputs, execution conditions, and expected results to verify if the system meets requirements. 4. Why is test case design important? It ensures effective testing coverage, reduces testing time, and helps find more defects. 5. Name some common test case design techniques. Equivalence Partitioning, Boundary Value Analysis, Decision Table Testing, State Transition Testing, Error Guessing, Use Case Testing. 6. What is Equivalence Partitioning? A technique that divides input data into valid and invalid partitions to reduce the number of test cases. 7. Give an example...