You are on page 1of 9

INFORMATICS

PRACTICES
POWERPOINT PRESENTATION

CHAPTER-2:GETTING STARTED WITH PYTHON

VISHNU CHOUDHARY
• INTRODUCTION:

-PYTHON WAS INVENTED BY GUIDO VAN ROSSUM,


AND FIRST RELEASED ON FEBRUARY 20, 1991
-PYTHON HAS A SIMPLE SIMILAR SYNTAX TO THE
ENGLISH LANGUAGE
-PYTHON WORKS ON DIFFERENT
PLATFORMS(WINDOWS,MAC,LINUX,ETC)
-PYTHON RUNS ON AN INTERPRETER SYSTEM,
WHICH MEANS THE CODE CAN BE EXECUTED AS
SOON AS IT IS WRITTEN. THEREFORE
PROTOTYPING CAN BE VERY QUICK GUIDO VAN ROSSUM
-PYTHON CAN BE TREATED IN A PROCEDURAL
WAY, AN OBJECT ORIENTED WAY OR A
FUNCTIONAL WAY
STEPS
TO DOWNLOAD PYTHON
• TO START, GO TO python.org/downloads AND
THEN CLICK SELECT THE LATEST VERSION OF
PYTHON TO DOWNLOAD.
WHY PYTHON?

-EASY TO USE
-DYNAMICALLY TYPED
-EXPRESSIVE LANGUAGE
-INTERPRETED LANGUAGE
-CROSS-PLATFORM LANGUAGE
-FREE AND OPEN SOURCE

WHY NOT PYTHON?


-NOT THE FASTEST LANGUAGE
-LESSER LIBRARIES THAN C,JAVA
-NOT EASILY CONVERTIBLE
-RUNTIME ERRORS
-NOT MEMORY EFFICIENT
-DESIGN RESTRICTIONS
WORKING IN SCRIPT MODE
If you need to write a long piece of Python code or your Python script spans multiple files, interactive mode is not
recommended. Script mode is the way to go in such cases. In script mode, You write your code in a text file then
save it with a .py extension which stands for "Python". Note that you can use any text editor for this, including
Sublime, Atom, notepad++, etc.

If you are in the standard Python shell, you can click "File" then choose "New" or simply hit "Ctrl + N" on your
keyboard to open a blank script in which you can write your code. You can then press "Ctrl + S" to save it.

After writing your code, you can run it by clicking "Run" then "Run Module" or simply press F5.

Let us create a new file from the Python shell and give it the name "hello.py". We need to run the "Hello World"
program. Add the following code to the file:

print(“Hello World”)

Click "Run" then choose "Run Module". This will run the program:
Output

Hello World
SCRIPT MODE ADVANTAGES
-It is easy to run large pieces of code.
- your script is easier in script mode.
-Good for both beginners and experts.

SCRIPT MODE DISADVANTAGES


- Can be tedious when you need to run only a single or a few
lines of code
- You must create and save a file before executing your code.

WORKING IN INTERACTIVE MODE

Interactive mode is where you type your code into the Python interpreter directly. This is useful for
trying out small snippets of code, or for testing things out as you’re writing them.
The >>> indicates that the Python shell is ready to execute and send your commands to the Python
interpreter. The result is immediately displayed on the Python shell as soon as the Python interpreter
interprets the command.

To run your Python statements, just type them and hit the enter key. You will get the results
immediately, unlike in script mode. For example, to print the text "Hello World", we can type the
following:
name=
age=26
course= "Computer Science"
print=>>> name = "Nicholas" >>> age = 26 >>> course = "Computer Science" >>> print("My name is "
+ name + ", aged " + str(age) + ", taking " + course)

Output

My name is Nicholas, aged 26, taking Computer Science

INTERACTIVE MODE ADVANTAGES

-Helpful when your script is extremely short and you want immediate results.
-Faster as you only have to type a command and then press the enter key to get the results.
-Good for beginners who need to understand Python basics.
INTERACTIVE MODE DISADVANTAGES

-Editing the code in interactive mode is hard as you have to move back to the
previous commands or else you have to rewrite the whole command again.
-It's very tedious to run long pieces of code.
-If we 'save the program the instructions' also get saved.

WORKING IN SPYDER IDE

Spyder is a powerful interactive development environment for the Python language with
advanced setting, interactive testing, debugging and introspection features. In fact, DataCamp
community recommends Spyder IDE comes preloaded with Anaconda distribution.

FEATURES OF SPYDER

-Customizable Syntax Highlighting


-Availability of breakpoints (debugging and conditional breakpoints)
-Interactive execution which allows you to run line, file, cell, etc.
-Run configurations for working directory selections, command-line options, current/ dedicated/
external console, etc
-Can clear variables automatically ( or enter debugging )
-Navigation through cells, functions, blocks, etc can be achieved through the Outline Explorer

You might also like