Python is a fast, flexible, beginner-friendly programming language. It’s gradual learning curve and readability make it an excellent choice for launching your adventures in coding. Python is also amazingly powerful. NASA, Google and Disney, to name a few, use it for everything from web applications to robots. Take a byte of Python and quickly learn to think like a programmer with our free videos and tutorials.
Writing Python Functions: Flow The Python interpreter reads a program just like you are reading this page: one line at a time, from left to right and top to bottom. The interpreter executes operations and functions in the order that it encounters them. This is called control flow or the flow of execution. Unlike the Python interpreter, when we read …
Python’s built-in functions are incredibly useful. Eventually you will find yourself repeating yourself. That’s bad. That’s when programming gets boring. Fortunately, you can write your own functions, which is why the first three letters of function are ‘F-U-N’. Writing Python Functions Now that we’re writing functions, you will want to use IDLE to create new files. It becomes tedious very …
Functions are like little machines in your program. You put something in the machine, press the start button, it works its magic and spits something out. Python functions are incredibly useful. They allow us to reuse code and simplify our programs. The last thing you want to do is waste your time rewriting the same thing over and over. Remember …
Life is like a Python list. You spend most of it in boxes. Sometimes the box is empty and sometimes the box is filled with different objects. And sometimes it’s a box within a box. I like to think of Python lists as boxes because the brackets look like a container. We make an empty box, or list, like this: …
There are several built-in methods that allow us to easily make modifications to strings in Python. In this tutorial we will cover the .upper(), .lower(), .count(), .find(), .replace() and str() methods. But first, let’s take a look at the len() method. While it’s not limited to strings, now is a good time to make the introduction. We use the built-in …
Did the excitement of the print() function wear off? There’s a lot more to strings than simply printing them out in IDLE. In this tutorial we will cover Python string operations: concatenation, multiplication, indexing and slicing. If you’re just joining us, you might want to check out our previous tutorial introducing strings. String Operations Think of strings like beads on …
“Hello, World!” Do you remember our first program? We used the print() function to output a line of text. The phrase “Hello, World!” is a string, and a string is a sequence of characters. We create a string by wrapping a sequence of characters in quotation marks. Even a single character is considered a string. So it follows that a …
Open your kitchen cupboard. In it you will find various means of storing food. Cardboard boxes, Ziplocs, Tupperware, plastic bags sealed with twist ties, and the focus of our discussion, storage jars. Computer memory is like a cupboard filled with storage jars. Using Python, you put values in the jars and then you put a label, a variable, on the …
Think of a number. Any number. Now, before you forget that number, let’s store it for later. When you think of a number, you are holding that value in your head. If you want to remember it later and your memory is like mine, you write it down on a piece of paper. And if it’s really important, you will …
Operator precedence determines the order in which operations are processed. In this tutorial, you will perform a mathemagical trick using nested parentheses to control Python operator precedence. If you’re just joining us, you may want to start with our previous post, Python Operators are Mathematical! Python Operator Precedence We now return to the continuing saga at Rossum’s Universal Robot Hospital. …