Registration for Weekly Python Exercise B1 (i.e., advanced level, part 1) closes in about 24 hours. Don’t be left out!WPE gives you exercises in all sorts of advanced Python topics: Data structures, functions, object-oriented programming, comprehensions, generators, and decorators. These exercises model real-world problems, so that when you encounter problems ...
Let’s say that you have a Python string, and want to grab a substring from it. The best way to do so is with a “slice”: >>> s = 'abcdefghij'>>> print(s[3:8])defgh In the above code, we’ve defined a string. We’ve then asked for the string to be returned, starting at ...
For more than 20 years, I’ve been teaching Python courses to companies around the world. This means that just about every day, I’m on the front lines of Python learning. I see, first-hand, what companies want people to learn and also what people are struggling to understand. The result is ...
Every so often, I’ve asked readers of my free, weekly “Better developers” newsletter to send me their Python problems. And every so often, I get a chance to answer their questions, going through their Python problems and trying to solve them. I’ve recently recorded and uploaded two videos with solutions ...
Let’s say that I want to write some Python code that invites the user to enter a number, and then prints that number, tripled. We could say: >>> n = input("Enter a number: ")>>> print(f"{n} * 3 = {n*3}") The good news is that this code works just fine. The ...
One of the first things that anyone learns in Python is (of course) how to print the string, “Hello, world.” As you would expect, the code is straightforward and simple: print('Hello, world') And indeed, Python’s “print” function is so easy and straightforward to use that we barely give it any ...