Python Principles

Blog

Sep 22 2019 18:55:34
Python Enumerate By Example

In Python, enumerate() is a built-in function. It is used to compute the indexes of a list while iterating over it. In other words, if you've ever found

Read more →
Sep 22 2019 18:55:34
Why Learn Programming

Technology is increasingly a large part of our lives. By learning to program, you can take advantage of this fact. Programming is a necessary skill for

Read more →
Sep 22 2019 18:55:34
What Is A Function

Understanding functions is crucial when learning to program. Different people need different explanations for functions to really click. So we'll try different

Read more →
Sep 22 2019 18:55:34
Convert a string to a list in Python

This post explains how to convert a string to a list in Python. If you need a list of words in the given string, use the built-in . split() method on the

Read more →
Sep 22 2019 18:55:34
How to get unstuck when programming

This post describes approaches and techniques for getting unstuck when programming, including debugging tips, and the varied ways programmers get stuck.

Read more →
Sep 22 2019 18:55:34
What Can You Do With Python

Python is a general-purpose programming language, which means that you can build essentially anything with it. You can use Python to automate boring tasks,

Read more →
Sep 22 2019 18:55:34
Name Errors

When you run Python code, you may get a NameError such as the following: The x in the error will vary depending on your program. The error means that Python

Read more →
Sep 22 2019 18:55:34
Check if a file exists in Python

Sometimes you need to check if a file exists on your file system. Here are different ways to accomplish this. The most Pythonic way to do this is to simply

Read more →
Sep 22 2019 18:55:34
Ways to reverse a Python string

There are different ways to reverse a string in Python. The usual way to reverse a string is to use slicing with a negative step: Breaking it down, string[:]

Read more →
Sep 22 2019 18:55:34
Python String ljust() explained

In Python, strings have a built-in method named ljust. The method lets you pad a string with characters up to a certain length. The ljust method means

Read more →
Sep 22 2019 18:55:34
Converting integer to string in Python

To convert an integer to a string, use the str() built-in function. The function takes an integer (or other type) as its input and produces a string as

Read more →
Sep 22 2019 18:55:34
Index Errors

You may sometimes get an IndexError such as the following when running your code: An IndexError means that your code is trying to access an index that

Read more →
Sep 22 2019 18:55:34
Lists Of Strings In Python

This post describes how to work with lists of strings in Python. Lists are one of the most common data structures in Python, and they are often used to

Read more →
Sep 22 2019 18:55:34
How To Approach A Coding Exercise

When you're struggling with solving a programming exercise, it helps to take a structured approach. First determine what to do. You can do this by writing

Read more →
Sep 22 2019 18:55:34
Key Errors

This error means that you're trying to access an invalid key in a dictionary. This is typically because the key does not exist in the dictionary. In other

Read more →
Sep 22 2019 18:55:34
Debugging By Simulation

When you're trying to understand someone else's code, or figure out why your own code isn't working, it is incredibly useful to understand precisely what

Read more →
Sep 22 2019 18:55:34
Print Vs Return

Printing and returning are completely different concepts. print is a function you call. Calling print will immediately make your program write out text

Read more →
Sep 22 2019 18:55:34
Roadmap For Learning To Code

This post describes what the overall process for learning to code is like. Reading it should give you an overview of what you will be learning as you progress

Read more →
Sep 22 2019 18:55:34
Type Errors

A TypeError means that you're trying to combine values of different types that are not compatible. For example, the following (wrong) code adds a string

Read more →
Sep 22 2019 18:55:34
Programming Project Ideas

One of the best ways to improve your programming skill is to work on a project that you find genuinely interesting. Here are some ideas for projects or

Read more →
Sep 22 2019 18:55:34
What Is Python

In a nutshell, Python is a popular and powerful programming language that is easy to learn. You write programs in Python to instruct your computer, telling

Read more →
Sep 22 2019 18:55:34
Why learn Python first?

Python is different from most languages. Python stands out from the rest by being simple, easy to learn, powerful, and can be used in nearly any field.

Read more →
Sep 22 2019 18:55:34
Syntax Errors

Syntax means the arrangement of letters and symbols in code. So if you get a syntax error, it usually means you've misplaced a symbol or letter somewhere

Read more →
Sep 22 2019 18:55:34
How to use JSON in Python

JSON is a way to represent data such as lists, numbers, and strings as text. This post explains how to encode, decode, and work with JSON in Python. To

Read more →
Sep 22 2019 18:55:34
Convert string to int in Python

Python has a built-in function that takes a string and converts it to an integer. Here are examples of how to use it, and how to handle errors.

Read more →
Sep 22 2019 18:55:34
How to split a string in Python

Strings are objects in Python. They have a method named split that lets you split the string. For example, here is a string containing commas that we split:

Read more →
Sep 22 2019 18:55:34
Python Strings

In this tutorial you'll learn how to create and work with strings in Python. Examples and practice exercises are included. A string is a sequence of letters.

Read more →
Sep 22 2019 18:55:34
Function Syntax

You can read about what functions are here. Here are some examples of simple functions: Here's how to call the functions: Here are all the parts that go

Read more →
Sep 22 2019 18:55:34
Check if a variable is a string in Python

To check if a variable contains a value that is a string, use the isinstance built-in function. The isinstance function takes two arguments. The first

Read more →