KEMBAR78
Getting Started With Python - Part 1 | PDF | Python (Programming Language) | Shell (Computing)
0% found this document useful (0 votes)
8 views3 pages

Getting Started With Python - Part 1

Uploaded by

diyaelma17
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)
8 views3 pages

Getting Started With Python - Part 1

Uploaded by

diyaelma17
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
You are on page 1/ 3

Getting Started with Python

GETTING STARTED WITH PYTHON


Part 1 - Introduction to Python Language

Introduction to Python
Python is an easy-to-learn, open-source high-level language developed by Guido Van
Rossum in 1991 at the National Research Institute for Mathematics and Computer Science,
Netherlands. It is based on the programming language ABC, which was a teaching language
created to replace BASIC, one of the pioneer programming languages.
The main features or advantages of Python are :
1. Beginner’s language – It uses simple English for keywords and easy syntax. This
makes it easy for a beginner to learn the language
2. Interpreter based– Unlike Java or C++, Python uses an interpreter, and hence it is
very easy to debug or correct errors in a program
3. Interactive Mode - It allows interaction with the interpreter directly to execute
statements and get the result immediately.
4. Dynamic type language - It does not require definition of data type for a variable,
the interpreter defines the data type by default.
5. Platform independent – It can run across any platform like Windows, UNIX, LINUX,
Macintosh, etc
6. Free and Open Source – It is freely available on the internet, and anyone can
download and use the language
7. Variety of applications – It has evolved into a powerful language, capable of creating
various types of application like web development, scripting, game development,
database applications, desktop GUIs, AI, etc.
Some disadvantages of Python are :
1. Performance and Speed : It is slower in execution as compared to other languages
like Jave or C++, etc, since it uses an interpreter which slows the execution, as it done
line by line.
2. Simplicity - It is a very simple language which makes the programmer accustomed to
its features, and make it tougher to learn other programming languages.
3. Memory Consumption : Since Python allows flexibility of data types, it uses a large
amount of memory for memory-intense programs
4. Difficult to Convert – Since Python has a very easy syntax, which is not supported in
most other languages, it is not easy to convert to another language

Installing and Working on Python


There are many Python distributions available on the internet, but it is better to use the
default installation available at the website https://www.python.org/downloads. This
distribution is referred as the CPython installation, which comes with the Python
interpreter, Python IDLE and the pip installer.

Computer Science with Python Class XI Page | 1 © Reeba John, Computer PGT, MTPS
Getting Started with Python

As per CBSE curriculum, it is recommended to install Python version 3.6.7 or above, and
install according to the operating system and memory settings on your computer. During
installation, remember to check the option for setting the Python Path.
Python IDLE (Integrated Development and Learning Environment) allows a user to
interactively type commands and also allows to create, edit, and execute programs, in a
single interface. Python IDLE can be used in two ways or modes :
1. Interactive mode (Python Shell) – In this mode, you can type a single command at
the Python prompt (>>>) and immediately get the result or output.
2. Script mode (Python Editor Window) – In this mode, you can create a new program,
edit and debug the program, save the program and finally execute the program.

Python Shell / Interactive Mode


When you start Python, you are entering the Python Shell or Interactive mode. Here you
can type any command, and get the output immediately on the screen.
Q.1. Using the Interactive mode, find the output of the following commands :
6*3
6+2*4
(6+2)*4
5-3-3
5-(3-3)
8/6
12/4+2
12/(4+2)

The print() function


The print() function is used to display something on the output window. The syntax of the
print() function in its simplest form is :
print(<objects to be printed>)
If a string has to be printed, it has to be enclosed in single quotes or double quotes. If there
are more than one objects to be printed, they have to separated using a comma.
For eg.
print('Hello World')
print('Welcome','to Python')
a=20
print(a)
print('a=',a)
b=5

Computer Science with Python Class XI Page | 2 © Reeba John, Computer PGT, MTPS
Getting Started with Python

print(b)
print('b=',b)
print(a,b)
print(a+b)
print(a-b)
print(a*b)
print(a/b)

Python Editor Window / Script Mode


The Interactive mode of Python allows you to type only one command at a time, and get the
result. If you want to get the output of a set of commands together, you have to create a
script or a program. You cannot save any of the commands you have done in Interactive
mode, but you can save the commands in the Script mode as a Python program.
To create a new program, goto the File menu, and select the New option or press the
CRTL+N keys. You will enter the Python editor window where you can type your commands.
For eg, open a new file and type the following commands.
print('Hello')
print('This is my first program')
After you have written the above lines of code, the next step is to save the program. Goto
the File menu, and select the Save option or press the CRTL+S keys. You will have to specify
a filename (for eg. first) and Python will save the file with the extension .py (first.py).
The next step is to execute or run the program. Goto the Run menu, and select the Run
Module option or press the F5 key. If there are any errors in the code you have written,
Python will display the error in the Python shell window, with the line number containing
the error. You can go back to the program and correct it, then save it and run it again. If
there are no errors in the program, you will see the output of the program in the Python
Shell window.
Hello
This is my first program
This program will be saved in your computer, and next time you start Python, you can open
and use the same program again. To open the file, goto the File menu, and select the Open
option or press the CRTL+O keys.

Q.2. Now write a program to print the following output


Learning Python
is going to be fun
I cannot wait to start

Computer Science with Python Class XI Page | 3 © Reeba John, Computer PGT, MTPS

You might also like