Python skills you should keep practicing to become a good coder, first part

A good coder has not achieved all their computer programming skills overnight, nothing happens without hard work and dedication. Having some experience with the Python computer programming language, it took me some years to truly realize that software development is not about just reading syntax or computer programming books, but about practicing and building stuff that works.

Although there are many skilled coders out there, whom one thinks that they can not match in terms of skills, I do believe that patience is a key factor in becoming a top notch computer programmer.

For one to master any craft, it is necessarily for them to practice it everyday, without stopping. Being smart is always a good thing, especially when it comes to writing and maintaining computer code, but consistency is the king if one wants to move their computer programming skills to the next level.

What's the one thing every developer wants? More screens! Enhance your coding experience with an external monitor to increase screen real estate.

Being a Python geek, lately I have started to practice the concepts which are necessarily for one to advance their computer programming skills with the Python scripting language. With the main purpose of helping others who are on the same journey of computer programming field, I decided to share a complete list of skills which one should keep practicing in order for them to reach an advanced level with the Python computer programming language.

Strings and the basic operations with them

Although most of the beginners in the Python computer programming language do think that strings are an easy concept to learn and implement in their software development projects, they have no idea about the best practices used by veteran developers who have many years of experience in the tech industry.

Like any other object in the Python scripting language, strings have their specifics too. For one to properly make use of them while coding their application in Python, it is truly important that they stay updated with the latest best practices shared by Python hackers from all over the world.

As most of the readers who have some experience with the Python computer programming language may know, string objects in Python can be easily indexed and sliced by using the syntax shown in the following example.

s = ‘codetheory’
s[0]
s[0:3]

Not only do string objects part of the Python computer programming language support indexing and slicing, but they also support concatenation. There are many ways to join strings in Python, but only a few of them are accepted and used by professional developers.

Based on my personal experience with the Python computer programming language, one can easily concatenate strings by using the addition arithmetic operation like shown below.

‘code’ + ‘theory’

The result of the above piece of code after it is being executed, is the one shown below.

‘codetheory’

A best practice when it comes to joining strings together in the Python computer programming language, is the technique being showed in the following example.

”.join([‘code’, ‘theory’])

The result of the above code is the same with that of concatenation by the addition operator.

‘codetheory’

A practical example in which I had to use the above technique in my Python project which I am currently developing, deals with the generation of video filenames.

For example, to generate the video filename ‘test.mp4’ I make use of the following code in my Python project.

‘.’.join([‘test’, ‘mp4’])

There are many methods that string objects in the Python computer programming language support. Most of them are very easy to read and remember for the Python coder.

If one wants to make all letters of their string in capital, all they have to do is run the method which is being shown in the following example.

‘lowercase’.upper()

Once the above Python code is being executed in the interactive mode, the following result is being produced on the console.

LOWERCASE

To transform the above string into a lowercase one, the Python coder can easily make use of the method being shown below.

‘LOWERCASE’.lower()

Once the above piece of Python code is being executed, the result shown below comes up in the Python interactive console.

‘lowercase’

There will be many cases in your Python projects in which you have to check if a string starts with a specific letter, or a group of letters.

Based on my personal experience with the Python computer programming language, the following technique is being used to find out if a string starts with a specific letter, or a specific group of letters.

s = ‘codetheory’
s.startswith(‘s’)
s.startswith(‘code’)

The information shared so far in this article about the string object in the Python computer programming language, is enough for the Python coder who wants to move their skills to the next level.

Lists, Tuples and Dictionaries

For a Python coder to move their skills to an advanced level, it is truly important that they practice some of the most used and some of the most important objects such as lists, tuples and dictionaries.

As many of you may know, all the Python objects mentioned above are mainly used by the coder to store information and specific data.

The syntax for declaring each one of the objects mentioned above is being shown below.

[] # list
() # tuple
{} # dictionary

As you may know lists are being used to store data that may change in time, tuples are being used to store data that can not change in time, and dictionaries are primarily used to store information which can be presented with keys and values.

A simple example which illustrates the usage of lists, tuples and dictionaries is being shown below.

l = [1, 2, 3, ‘changes’]
t = (1, 2, 3, ‘doesnotchange’)
d = {‘name’: ‘oltjano’, ‘job’: ‘student’}

Each one of the objects declared in the above example, has a specific role which the Python coder utilizes in their software development projects.

The list object can be utilized to store data which can change in a specific point in time. For example, the Python coder can store the titles of its books in a Python list object like shown below.

my_book_titles = [‘Meriyll’, ‘The Code Of Silence’, ‘Psalms’, ‘Fruits Of The Holy Spirit’]

Because one may make one of their books as a gift to their friend, they have to remove its title from their Python list by using the builtin pop method, which is specific to the Python list object; like shown below.

my_book_titles.pop(3)

Once the above piece of Python code gets executed in the interactive shell, the list named my_book_titles changes its state.

On the other side, the Python tuple object is being used to store data which does not change in time; for example the IP addresses of servers which one wants to connect with through their application.

ips = (192.168.1.1, 127.0.0.1, 192.168.0.0)
for ip in ips:try_to_connect(ip)

While the Python list object and the tuple one may seem similar, the dictionary object is totally different from them, as it stores data based on keys and values.

The Python coder can make use of the Python dictionary object to store detailed information about something, or someone. A practical example in which one may use the Python dictionary object, is the one in which they need to store information about a worker, or a student.

student = {‘name’: ‘StudentA’, ‘last_name’:’Smith’, ‘class’: ‘engineering’, ‘age’: 21}

As you can see from the example which is being shown above, the Python dictionary object fits perfectly when it comes to storing detailed information and data which describes something or someone.

Functions

Functions in the Python computer programming language are very important as they help the coder to group statements together with the main purpose of achieving a specific goal and also help them to stop repeating themselves in their software development projects.

As most of you may know, one can easily declare a function in the Python computer programming language by using the following syntax.

def my_func():pass

When used in real world projects, functions part of a computer programming language, must return something to the caller. For example, the function being shown below, returns back the sum of two numbers to the caller.

def find_sum(a, b):return a + b

Final thoughts

Consistency is the key in becoming good at any craft! The Python concepts shared through this first part, are truly important for one to practice over and over if they truly want to get good in terms of coding skills.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Leave a Reply

Your email address will not be published. Required fields are marked *

*