Want to create interactive content? It’s easy in Genially!

Get started free

Writing a Python Script

Ria Dalvi

Created on March 11, 2025

Start designing with a free template

Discover more than 1500 professional designs like these:

Transcript

Writing a Python Script

Learn how to create, run, and under your first Python script.

Start

Objectives

By the end of this guide, you will:

  • Install Python on your machine.
  • Write a simple Python script.
  • Run the script and understand its output.
  • Learn basic Python syntax (variables, loops, and functions).

Modules and Summary

Index

Activities

Evaluation

Getting Started with Python

Learn how to install Python and set up your environment.

Modules

Writing Your First Script

Learn how to write and run your first script.

Enhancing Your Script

Learn how to add instructions to enhance your script.

Getting Started with Python

What is Python?

  • Python is powerful yet beginner-friendly programming language known for its clarity and flexibility
  • Some of its key feature include:
    • Easy to learn and write (uses plain English-like syntax)
    • Versatile (works for web apps, AI, automation, and more)
    • Huge community support and libraries

+Info

Getting Started with Python

Installing Python

  1. Go to the official Python website: https://www.python.org/downloads/
  2. Download the latest version of Python for your operating system (Windows, Mac, or Linux).
  3. During installation, check the box that says "Add Python to PATH" (this makes it easier to run Python from the command line).

Verify your installation by opening a terminal or command prompt and typing:python --version

Getting Started with Python

Setting up Your Environment

  1. Create a folder for your Python projects using these commands:
    1. mkdir python-projects
    2. cd python-projects
  2. Create a new file for your script:
    1. touch my_first_script.py
  3. Install a text editior like:
    1. VS Code
    2. Sublime Text

Folder structure for python project

Writing Your First Script

Writing a Script

  1. Open my_first_script.py in your text editor.
  2. Add the following code:
    1. print("Hello, World!")
  3. Save the file.

Writing Your First Script

Running the Script

  1. Open a terminal or command prompt.
  2. Navigate to your project folder:
    1. cd path/to/python-projects
  3. Run the script:
    1. python my_first_script.py
  4. You should see the output:
    1. Hello, World

+ Activity 1

Enhancing Your Script

Add Variables and User Input

  1. Update your script to include variables and user input:
    1. name = input("What's your name? ")
    2. print(f"Hello, {name}! Welcome to Python."
  2. Run the script and interact with it.

+ Activity 2

Enhancing Your Script

Add a Loop

  1. Modify your script to include a loop:
    1. times = int(input("How many times should I greet you? "))
    2. for i in range(times):
print(f"Hello, {name}! (Time {i+1})") 2. Run the script and see the loop in action.

+ Activity 3

Enhancing Your Script

Add a Function

  1. Add a function to make your script more modular:
    1. def greet_user(name, times):
for i in range(times): print(f"Hello, {name}! (Time {i+1})") b. name = input("What's your name? ") times = int(input("How many times should I greet you? ")) greet_user(name, times) 2. Run the script and observe how the function works.

+ Activity 4

Activity 1

First Script Activity

Activities

Activity 2

Variables and Input Activity

Write a great subtitle hereto provide context

Activity 3

Loops Activity

Activity 4

Functions Activity

Back to Module

Activity Relate key concepts

Activity 1

Modify the script to print your name instead of "Hello, World!" and run it again.

Solution

Back to Module

Activity Relate key concepts

Activity 2

Modify the script to ask for the user’s age and print a personalized message (e.g., "You are 25 years old.").

Solution

Back to Module

Activity Relate key concepts

Activity 3

Modify the loop to count down instead of up (e.g., "Hello, Alice! (Time 3)").

Solution

Back to Module

Activity Relate key concepts

Activity 4

Add a new function that asks for the user’s favorite color and prints it.

Solution

Evaluation

1/3

Evaluation

2/3

Evaluation

3/3