Should I Use Elif In Python?

When working on complex projects, you may encounter a situation where you need to make decisions based on multiple conditions. That’s one of the first things I got to know as a new QA engineer who later became a Python developer.

This is where the elif statement in Python comes in.

In this article, we’ll explore what the elif statement is, how it works, and when to use it in your code.

I’m going to answer the “Should I Use Elif In Python?” question based on my experience.

Continue reading

Is It Worth It To Do A Python Certification?

When you first think about learning Python and becoming a Python developer you must have thought or heard about Python certification. I started my career as a QA engineer and I was in the same situation as you. I’ll answer the “Is It Worth It To Do A Python Certification?” question based on my personal experience in this post!

Is It Worth It To Do A Python Certification?

Yes, but whether or not a Python certification is worth it depends on your goals and the specific certification you are considering.

Certification can demonstrate a level of knowledge and proficiency in the language, which can be beneficial for Python beginners seeking jobs or those looking to advance in their careers.

However, I can tell you from my own personal experience, employers value real-world experience and a portfolio of projects so gaining hands-on experience through personal projects and internships is way more important than just having a Python certification.

Continue reading

How Do I Store Python Logs In A File?

In many Python programming situations, at some point, as your application grows you want to start storing logs in a file. Since the very early days ( about my Python experience here ) that was the case for me. In this post, I’ll share my ideas for the “How Do I Store Python Logs In A File?” question.

How Do I Store Python Logs In A File?

One way to store these Python logs in a file so you can look at them later is to write them to a file using a built-in logging module. 

Here’s an example of how to use the logging module to store logs in a file in Python:

import logging

# Configure the logging module to use a file
logging.basicConfig(filename='example.log', level=logging.DEBUG)

# Write some log messages
logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')

In this example, the basicConfig() function is used to configure the logging module to write logs to a file named ‘example.log’.

The level argument is set to logging.DEBUG which means that all log messages, including debug, info, warning, error, and critical messages, will be written to the file.

Then the code uses different logging levels debug(), info(), warning(), error() and critical() to write different log messages.

When you run this code, it will create a new file called ‘example.log’ in the same directory as your script, and the log messages will be written to it.

Obviously, this is a very simplified version of logging in Python, I’ll get into more details and other examples in the following sections of this post.

Continue reading

What Is Python Programming In Short?

The first time you hear about Python Programming you kind of want to explore and understand the capabilities of the language. This is exactly what happened to me when one of my university professors told me about Python and I was just a QA engineer at that time. The first question that came to my mind was: “What Is Python Programming In Short?”. Let me explain…

What Is Python Programming In Short?

As a Python developer who has been using Python for several years now, I can confidently say that it is an incredibly powerful and versatile programming language.

Python is a high-level, interpreted language, which means that it is easy to read and write, and you don’t need to worry about low-level details like memory management and compiling code.

Python is great for beginners who never coded anything before.

I used to be one years ago and all I wanted to do was to just start building a script or a small project, just to start understanding programming from a practical standpoint, not just in theory.

Continue reading

What Python Projects Should I Build To Get A Job?

When you first get into Python and realize you actually want to become a Python developer, you find yourself asking “What Python Projects Should I Build To Get A Job?”. Years ago, when I was still working as a QA engineer, I had the same question. In this post, I will share my insight and what type of projects I recommend my Python Mentoring students build.

What Python Projects Should I Build To Get A Job?

There are many different Python projects you can build to improve your skills and make yourself more marketable in the job market. If you already know which type of industry you want to work in, I’d recommend you build a Python project that is relevant to that industry.

That’s exactly how I got my first Python job and several of my students are following the same steps.

This approach will help you gain experience with the types of technologies and problems that you will encounter in your desired industry, and will make you a more attractive candidate for job opportunities in that field.

Continue reading

What Is The Order To Learn Python?

Years ago, when I first got into learning Python (while I was still a QA engineer) I wasn’t sure about the order in which I should learn Python. So, what is the order to learn Python? Let’s look into the most common topics and questions people ask when it comes to learning Python properly.

What Is The Order To Learn Python?

As a Python developer with 7+ years of experience, I can say that it’s important for you as a beginner to learn Python in a specific order.

Start with the basic concepts of programming, such as the following:

  • Variables
  • Data types
  • Loops
  • Control structures

These will give you a solid foundation and understanding of fundamentals. From there, you can move on to:

  • Learning the syntax of Python
  • How to write and run programs
  • How to define and call functions
  • How to work with modules.
Continue reading

How Do I Search For A Pattern In Python?

A couple of years back when I was still a QA engineer (not a Python developer yet) I got myself into dozens of situations where I had to figure out how do I search for a pattern in Python.. A pattern in strings, a pattern in files, etc. Let’s look into possible solutions in this post.

How Do I Search For A Pattern In Python?

To search for a pattern in a string in Python, you can use the re module, which stands for regular expression. Regular expressions are a way to describe patterns in strings, and the re module provides several functions to work with them in Python.

Suppose you have a list of emails, and you want to extract the username and domain name from each email address.

The emails look like this:

jane.doe@example.com
john.smith@gmail.com

You can use the re module and regular expressions to extract the username and domain name from the email addresses like this:

import re

email = 'jane.doe@example.com'

# Extract the username and domain name using a regular expression
pattern = r'(.+)@(.+)'
match = re.search(pattern, email)

username = match.group(1)
domain = match.group(2)

print(f'Username: {username}')  # Output: 'Username: jane.doe'
print(f'Domain: {domain}')  # Output: 'Domain: example.com'

In this example, we used the re.search() function to find the first occurrence of the pattern in the email address, and then used the group() method to extract the matching substrings.

The regular expression itself uses several special characters to specify the pattern:

  • . matches any single character (except a newline)
  • + matches one or more occurrences of the preceding character
  • ( ) define a capturing group, which allows us to extract the matching substrings using the group() method
Continue reading

Can I Learn Python By Myself? 

Back in the day, when I used to work as a QA engineer and learn Python on the side I was very passionate about programming, but I also had no one to help me out at first. One of the main questions I had was: “Can I Learn Python By Myself?” Let me tell you about my experience and to what conclusion I came.

Can I Learn Python By Myself?

Yes, it is possible to learn Python on your own to a degree.

Let me explain what I mean by “to a degree”.

You won’t become an expert on your own and you’ll miss a lot of key concepts professionals use in the industry every day, but you can learn all the basics on your own with tons of research and time investment.

There are many resources available that can help you get started, including online tutorials, books, and video courses, but to become a real professional Python developer you’ll likely have to find mentors to become reasonably good and to be able to work alongside other professional Python developers.

Here are a few steps you can follow to start learning Python on your own:

Continue reading

Can I Earn Money If I Know Python?

When I was fresh into the IT industry, working as a QA engineer, I used to look for skills I could learn to earn more money. One of the questions that came to my mind was: “Can I earn money if I know Python?” Let’s look into possible answers in this post.

Can I Earn Money If I Know Python?

Yes, you can earn money by knowing Python. Python is a popular programming language that is widely used in a variety of industries, including finance, healthcare, education, and software development. There are many ways in which you can use your Python skills to earn money, including:

  1. Freelancing: You can offer your Python skills as a freelancer and work on a variety of projects for different clients.
  2. Working as a software developer: Many companies are looking for Python developers to build and maintain software applications.
  3. Data analysis and machine learning: Python is a popular language for data analysis and machine learning, and there is a high demand for professionals who can use these skills to help organizations make data-driven decisions.
  4. Teaching: You can also teach Python to others and earn money through tutoring or creating online courses.

Overall, there are many opportunities for individuals who know Python to earn money, and the demand for Python skills is likely to continue growing in the future.

Continue reading

How Do You Repeat Code In Python?

One of my first tasks as a new QA engineer / Python dev back in the day was to figure out how do you repeat code in Python, how to iterate from 0 to 10 in Python or how do I repeat code in Python forever. Let’s look into possible solutions in this post.

How Do You Repeat Code In Python?

There are a few ways to repeat code in Python, but for loops are a very common way to repeat code in Python, especially when you need to iterate over a sequence of items (such as a list, tuple, or string).

They are easy to use and can be more efficient than using a while loop, especially when you know exactly how many times you need to repeat the code.

To repeat a block of code a specific number of times use:

# Repeat 5 times
for index in range(5):
    print(f'iteration index: {index}')
Continue reading