CH 1-Modes in Python
CH 1-Modes in Python
KINGDOM OF BAHRAIN
Introduction to Python:
Features of Python
• Python programs are easy to understand as they have a clearly defined syntax and
• Python is case-sensitive. For example, NUMBER and number are not same in Python.
• Python is portable and platform independent, means it can run on various operating
• Python is also helpful in web development. Many popular web services and
Interactive Mode:
❖ Allow us to interact with the operating System.
❖ Commands are executed line by line and give output at the same time when the enter key is
pressed.
❖ Commands are typed in front of Python commands prompt >>>
❖ IDLE -integrated development and learning environment.
The interactive mode is great for testing out commands and getting immediate feedback.
It can also be used to quickly execute commands on a remote server.
a. Script Mode that enable us to create and edit python source file.
b. Files in python are saved with extension .py
c. Here File is created and save for future reference.
d. Code is written on the editor like Notepad.
It is a way of executing a Python In the script mode, the Python program is written in a
program in which statements are file. Python interpreter reads the file and then
written in command prompt and result executes it and provides the desired result. The
is obtained on the same. program is compiled in the command prompt,
The interactive mode is more suitable Script mode is more suitable for writing long
for writing very short programs. programs.
Built-in function input () can be used to get the input from the user interactively as follows:
• Input() always returns value of the string data type hence below error occurs.
• Even though the age entered is a number, input() returns it as a string value.
• sep: It is an optional parameter used to define the separation among different objects to be
printed. By default an empty string(“”) is used as a separator.
• end: It is an optional parameter used to set the string that is to be printed at the end. The
default value for this is set as line feed(“\n”).
• What is \r in python?
• What is \b in python?
1.4 USE OF COMMENTS
Comments can be used to :
Types :
2. Multiline Comment
3. Inline Comment
http://python.mykvs.in/uploads/tutorials/XIComp.Sc.58.pdf
https://youtu.be/PQO-DyK3R2M?feature=shared