0% found this document useful (0 votes)
7 views1 page

Python Basics: Script vs Interactive Mode

The document discusses Python programming modes, highlighting the differences between interactive and script modes. It emphasizes the importance of saving code in script mode for reuse and modification, while interactive mode is suitable for learning and experimentation. Additionally, it covers the concept of variables, their identity, type, and value in programming.

Uploaded by

darkflux514
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Python Basics: Script vs Interactive Mode

The document discusses Python programming modes, highlighting the differences between interactive and script modes. It emphasizes the importance of saving code in script mode for reuse and modification, while interactive mode is suitable for learning and experimentation. Additionally, it covers the concept of variables, their identity, type, and value in programming.

Uploaded by

darkflux514
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Science

>>> y=20
>>> print x*y
200
Script Mode: In script mode, we type Python program in a file and then use interpreter to execute the
content of the file. Working in interactive mode is convenient for beginners and for testing small pieces of
code, as one can test them immediately. But for coding of more than few lines, we should always save our
code so that it can be modified and reused.
Python, in interactive mode, is good enough to learn, experiment or explore, but its only drawback is that
we cannot save the statements and have to retype all the statements once again to re-run them.
Example: Input any two numbers and to find Quotient and Remainder.
Code: (Script mode)
a = input ("Enter first number")
b = input ("Enter second number")
print "Quotient", a/b
print "Remainder", a%b
Output: (Interactive Mode)
Enter first number10
Enter second number3
Quotient 3
Remainder 1
Variables and Types: One of the most powerful features of a programming language is the ability to
manipulate variables. When we create a program, we often like to store values so that it can be used later.
We use objects (variables) to capture data, which then can be manipulated by computer to provide
information. By now, we know that object/variable is a name which refers to a value.
Every object has:
2
An Identity,
2
A type, and
2
A value.
A. Identity of the object is its address in memory and does not get change once it is created. We may know
it by typing id (variable)
We would be referring to objects as variable for now.
B. Type (i.e data type) is a set of values, and the allowable operations on those values. It can be one of the
following:

You might also like