Example
For Loop with enumerate and range
Functions enumerate() and range() extend for loop capabilities in Python.
Showing 1–10 of 202
Example
Functions enumerate() and range() extend for loop capabilities in Python.
Example
For loop iterates through sequence elements. Basic iteration over lists.
Quiz
Free beginner quiz on Python for loops: 15 questions on lists, strings, range(), enumerate(), totals and break, with instant answers.
Challenge
Ask for an engine burn length with input(), turn it into a number with float() and work out the propellant it uses, then read the tank level too and show what the burn leaves.
Example
F-strings are a modern way to format text in Python. Insert variables directly into text.
Challenge
…prints 12 , but {seconds} prints 5 , not 05 . Add a format spec after a colon: {seconds:02} means "at least 2 characters wide, filled with zeros".
Article Python Fundamentals
…space-themed examples and hands-on exercises. Perfect for beginners who want to chart the control flow of their programs.
Article Python Fundamentals
…and these two books consistently deliver results - though for very different reasons. Let's see which learning style matches yours.
Challenge
Move the mission log's f-string into format_log(t, level, msg), a function that returns the line instead of printing it, then fix the alignment of every log line with one change inside the function.
Challenge
…is ten orbits long, and the flight log should have a line for each one. The log always ends one orbit early, and the last orbit, the one that matters for the landing, is never in it. Predict the last…