CBSE Class 11: Python Fundamentals 4

Working 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