Let's Python with Vijin (Part-2)

Let's Python with Vijin (Part-2)


Working with Python

To write a python program we need Python Interpreter also called Python IDLE.

Execution Mode

We can use python interpreter in two different modes:

·?????? Interactive Mode

·?????? Script Mode

Interactive Mode

·?????? Instant Execution of individual statement.

·?????? As soon as you press enter, the interpreter executes the statement and displays the result(s).

·?????? Convenient for testing single line of code.

·?????? We can not save statements for future use.

Python shell

Script Mode

·?????? Allows us to write and execute more than one instruction together.

·?????? We can save programs (python script) for future use.

·?????? Python scripts are saved as file with extension “.py”.

·?????? By default, the python scripts are saved in python installer folder.

Steps to be followed in script mode

1.???? Goto File-à New File (Ctrl+N)

2.???? New File will be opened

3.???? Type your program there

Script Mode

4.???? Save your program in desired location (Ctrl+S)

I have saved the program in the following location:

File Name is given as FirstProgram and Type is selected as Python files

The program will be saved as FirstProgram.py

Location: C:\Users\vijin\FirstProgram.py

5.???? Now, Let’s execute (run) the program.

The program can be executed in two different ways:

i.??? Run the program directly from IDLE (F5):

Output:

i.??? Run the program through command prompt

a.???? Search for cmd

b.???? Select Command Prompt

c.???? Locate your file using CUI commands

(cd? filename --> to enter the file)

(cd .. -->to come out of file)

d.???? Type File name.py to get the output


要查看或添加评论,请登录

VIJIN K的更多文章

社区洞察

其他会员也浏览了