Challenge
Silent branch
…returns None for Scrub because that branch sets a variable but never returns it. Predict the last line, find which statuses give None, make every path return, then write a function where every path…
Showing 31–40 of 53
Challenge
…returns None for Scrub because that branch sets a variable but never returns it. Predict the last line, find which statuses give None, make every path return, then write a function where every path…
Example
The global keyword allows modifying a global variable inside a function.
Article Python Fundamentals
…is what sets it apart. Let's look at some basic elements: Variables and Data Types In Python, variables are like containers that hold data. You don't need to declare a variable's type explicitly…
Challenge
…thousands. Investigate and modify Investigate. Find the variable that holds a distance in a different unit and store its name, as text, in odd_one_out . Then convert it: one mile is 1.609344 km. Store…
Quiz
…does, including leaving a function early Local and outside variables, and lists passed into a function Docstrings, calling one function inside another and passing a function as a value How it works 15…
Challenge
…It repeats the same twelve lines for each engine, the variables are called t , m and s , and a fourth engine is being installed next month. Restructure it without changing a single character of what…
Challenge
…of (name, level) pairs and one loop. Keep the three level variables, which come from telemetry. The output must stay exactly the same: Tank A: 78.3% Tank B: 12.5% LOW Tank C: 46.0% Build tanks =…
Quiz
…questions built on the topics of the earlier quizzes, from variables and strings to lists, dictionaries and functions. For each piece of code you decide which error it raises, read the message, or…
Quiz
…this one, try the Python Data Types Quiz or the Python Variables Quiz .
Challenge
…puts x at index 1, and crew.remove(x) deletes it. Use the variables, not the names. Reassigned After the changes, the newest member, now last in the list, is reassigned to the space station. Take them…