Create a Rocket Launch Countdown

PythonPythonBeginner
Practice Now

Introduction

Welcome to the LabEx Space Academy's Python Loop Challenge! As a new recruit, you've been assigned to create a simple countdown program for rocket launches. This challenge will test your ability to use loops in Python, a crucial skill for automating repetitive tasks in space missions.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL python(("Python")) -.-> python/ControlFlowGroup(["Control Flow"]) python/ControlFlowGroup -.-> python/while_loops("While Loops") subgraph Lab Skills python/while_loops -.-> lab-393128{{"Create a Rocket Launch Countdown"}} end

Rocket Launch Countdown

In this challenge, you will create a Python script that performs a countdown for a rocket launch.

Tasks

  • Create a Python script named countdown.py in the /home/labex/project directory. (Recommend to use WebIDE)
  • Write a program that does the following:
    1. Starts a countdown from 10.
    2. Prints each number in the countdown, one per line.
    3. After reaching 0, prints "Liftoff!"

Requirements

  • The script must be named countdown.py and located in the /home/labex/project directory.
  • Use a for loop with the range() function to create the countdown.
  • Each number should be printed on a new line.
  • After the loop completes, print "Liftoff!" on a new line.
  • The script should run without any errors.

Example

After running the script, the output should look exactly like this:

10
9
8
7
6
5
4
3
2
1
0
Liftoff!
โœจ Check Solution and Practice

Summary

In this challenge, you have created a Python script that performs a countdown for a rocket launch. This exercise has reinforced your understanding of loops in Python, specifically using a for loop with the range() function. You've practiced creating a script that executes a repetitive task (counting down) and finishes with a specific action (printing "Liftoff!"). These fundamental skills in loop control are essential for many programming tasks you'll encounter in your journey as a space academy programmer.