Example
The global Keyword
The global keyword allows modifying a global variable inside a function.
Showing 21–30 of 40
Example
The global keyword allows modifying a global variable inside a function.
Example
Looping through keys, values or key-value pairs of a dictionary.
Example
Lists store multiple elements in a specific order. Basics of working with lists.
Example
Order of operations in Python. Parentheses, exponents, multiplication, division, addition.
Challenge
…of log Run, read, fix, repeat Day 3 has two mistakes, on different lines. Python reports only the first one it finds, so after you fix it and run again, a different error appears, on a different line…
Challenge
…between two points comes from Pythagoras: square the differences in x and in y, add them, and take the square root. Distance A to B: 600.0 m ** raises a number to a power: dx ** 2 is dx squared, and…
Challenge
…weighs, because food, life support and spares go into different racks with different mass limits. Total the manifest by category, then rank the categories by mass. A total per category Add up the mass…
Challenge
…and whether this is only a dry run. Each setting is a different kind of value, and Python treats each kind differently. This challenge works in three steps. First you predict what some code prints and…
Challenge
…starts with that line, because the same code can behave differently in different versions. Python can tell you itself. Write the first lines of a bug report for the Python One flight software, filled…
Article Python Fundamentals
…text list. Both do the same scanning, just display results differently. Common Beginner Mistakes Mistake 1: Same Variable Names # BAD - inner loop overwrites x! for x in range(3): for x in range(3): #…