Programming in script mode

To work in script mode we have to create a file to store the python program.

Firstly start IDLE of python then:

1. File->new File (Ctrl+N)
2. Save the file with extension as .py

 

Example:1
python script to calculate and the print sum of two number.
Sol:

Program name: sum.py

 

a=10
b=20
c=a+b
print("1st no = ",a)
print("2nd no = ",b)
print("Sum = ",c)

Output:
save the file, run/execute the file (Run->Run Module / F5 )

1st no =  10
2nd no =  20
Sum =  30
>>> 

Example:2
python script to calculate and print square of a no
Sol:

a=10
b=a*a
print("number = ",a)
print("square = ",b)

Output:
save the file, run/execute the file (Run->Run Module / F5 )

number =  10
square =  100

Python Basic Programming Tutorial

Python Introduction     Getting started in Python Programming      Python propgramming fundamentals     Python Operators    Python If Condition     Python for loop    Python range construct      Python While loop    break and continue statements     Different looping techniques     Python List     Python String     Python Functions    Python Inbuilt Functions     Python Recursion     Using Python Library     Python Tuples     Python Dictionary     Python Sets     Python Strings     Python Exception Handling     Python Data File Handling