0% found this document useful (0 votes)
2 views

Python Basics

The document explains how to start and end Python, detailing the two modes: Interactive Mode for quick testing and Script Mode for writing full programs. It provides instructions for running Python scripts by creating a .py file and executing it in the terminal. Examples are included to illustrate the usage of both modes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Basics

The document explains how to start and end Python, detailing the two modes: Interactive Mode for quick testing and Script Mode for writing full programs. It provides instructions for running Python scripts by creating a .py file and executing it in the terminal. Examples are included to illustrate the usage of both modes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python basics:

1.1 How to start and end python?

To Start:

On windows:

 Cmd -> type “python” or py -> enter

To End:

 Ctrl + z -> enter / quit() -> enter

1.2 Modes in Python:

2 Modes:

1. Interactive Mode
2. Script Mode

1. Interactive Mode:

 Runs one line at a time.

 Good for quick testing and small calculations.

 Starts when you type python or python3 in the terminal.

 Example:

>>> 5 + 3

This is called Interactive Mode because Python runs each line immediately as you type.

2️. Script Mode:

 Used to write full programs in a file (with .py extension).

 Runs the entire file at once.

 Good for building applications and projects.

 To run a script, save it in a file (example.py) and run:

python example.py

 Example (example.py file):

name = "Varshini"

print("Hello,", name)

Output:

Hello, Varshini

Summary:
 Interactive Mode: For quick testing.
 Script Mode: For real projects and large programs.

How to Run a Python Script?

Instead of typing everything in the terminal, you can write code in a file and run it.

1. Create a file hello.py and write:

print("Hello, Python!")

2. Save it and run it in the terminal:

python hello.py

Output:

Hello, Python!

You might also like