Module 1 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

What is computer?

A computer is an electronic device that


manipulates information, or data. It has the
ability to store, retrieve, and process data.
HOW DO HUMAN
COMMUNICATE WITH
COMPUTER?

A COMPUTER COULD NOT


UNDERSTAND HUMAN
LANGUAGE
EACH PROGRAM IS UNIQUE
Lets assume that a
programming language is
a vehicle. There are many
kinds of vehicle, with
different size, different
characteristic and
different purpose.
COMPILED LANGUAGE
INTERPRETER LANGUAGE
ARTIFICIAL INTELLIGENCE
In December 1989, I was looking for a "hobby"
programming project that would keep me
occupied during the week around Christmas.
My office (...) would be closed, but I had a
home computer, and not much else on my
hands. I decided to write an interpreter for the
new scripting language I had been thinking
about lately: a descendant of ABC that would
appeal to Unix/C hackers.
Python was originally conceptualized by Guido
van Rossum in the late 1980s as a member of the
National Research Institute of Mathematics and
Computer Science. Initially, it was designed as a
response to the ABC programming language that
was also foregrounded in the Netherlands.
Among the main features of Python compared to
the ABC language was that Python had exception
handling and was targeted for the Amoeba
operating system (go Python!).
PYTHON GOALS!
In 1999, Guido van Rossum defined his goals for Python:
• an easy and intuitive language just as powerful as those of the
major competitors;
• open source, so anyone can contribute to its development;
• code that is as understandable as plain English;
• suitable for everyday tasks, allowing for short development
times.
Fun fact. Python is not
named after the
snake. It’s named after
the British TV show
Monty Python.
PYTHON HISTORY
WHY PYTHON?

Solve complex
problems in less
time with fewer
lines of code
HUGE CROSS-
HIGH-LEVEL
COMMUNITY PLATFORM

LARGE
ECOSYSTEM

WHY PYTHON?
WHY
PYTHON?
A multi-purpose language with
a simple, and beginner –
friendly syntax

WHY PYTHON
PYTHON DRAWBACKS
• it's not a speed demon - Python does not deliver exceptional performance

• in some cases it may be resistant to some simpler testing techniques - this may
mean that debugging Python's code can be more difficult than with other
languages; fortunately, making mistakes is always harder in Python.
PYTHON DRAWBACKS

Despite Python's growing popularity, there are still


some niches where Python is absent, or is rarely seen:

• low-level programming (sometimes called "close to


metal" programming): if you want to implement an
extremely effective driver or graphical engine, you
wouldn't use Python;
• applications for mobile devices: although this
territory is still waiting to be conquered by Python, it
will most likely happen someday.
Python 2 vs Python 3

Python aka Cpython


There is more
than one Cython
Python
Jython

Pypy and Rpython


Python 2 vs Python 3

• Python 2 is an older version of the original Python.


• Its has not been developed
• The updates are issued on regular basis, like fixing bugs and security holes
• Python 2's development path has reached a dead end already.
• Python 3 is the newer version of language
• These two versions of Python aren't compatible with each other.
• Python 3 is better than python 2
Basis of comparison Python 2.X Python 3.X

Function print print 9/4 print(9/4)


print “cta” print(“cta”)

Division of Integers When two integers are divided, Whenever two integers are
you always provide integer value. divided, you get a float value

Python version 3 is not


Not difficult to port python 2 to
Backward compatibility backwardly compatible with
python 3 but it is never reliable.
Python 2.

Differences between Python 2


& Python 3
CPython:
CPython
and • Maintained by the people gathered around the PSF
(Python Software Foundation)Python aka Cpython
Cython • These Pythons are called canonical
• Considered to be reference Pythons
• All Pythons coming from the PSF are written in the
"C" language.

Cython:

• Cython is a C extension of Python.


• Cython can call C functions.
"J" is for "Java".

Jython
Python written in Java

Jython can communicate with existing


Java infrastructure more effectively.
The current Jython implementation
follows Python 2 standards.
PyPy - a Python within a Python
PyPy
and
RPython A Python environment written in Python-like
language named RPython (Restricted Python).

A tool for people developing Python than for


the rest of the users.

PyPy is compatible with the Python 3


language.
How to get Python & For Windows user, start the downloaded .exe file
and follow all the steps.

How to get to use it https://www.python.org/downloads/


• To start your work, you need the following
tools:
• an editor, to support in writing the code
• a console, to launch newly written code
How to get and stop it forcibly when it gets out of
control
Python & • a tool named a debugger, able to launch
your code step by step and allowing you to
How to get to inspect it at each moment of execution.

use it • Python 3 standard installation contains a very


simple but extremely useful application named
IDLE.
How to write and run your very first program
Click File in the IDLE’s menu and choose New file.
How to write and run your very first program
Click File (in the new window), then click Save as...,
How to write and run your very first program
Write : print(“Hello World”)
How to write and run your very first program
Click Run, then click Run Module (F5)
• Click File, Open, point to the file you saved
How to spoil and fix previously and let IDLE read it in.

your code • Remove the closing parenthesis.


How to spoil
and fix your
code

• Press F5
• The editor window shows clearly where it happened.
How to spoil
and fix your
code

• Back to editor window


• Remove t on print
• The editor window will not provide any useful
information regarding the error, but the console
windows might.
• The message (in red) shows (in the subsequent lines):
• the traceback (which is the path that the code
traverses through different parts of the program -
you can ignore it for now, as it is empty in such a
How to spoil simple code);

and fix your • the location of the error (the name of the file
containing the error, line number and module
code name);
• the content of the erroneous line; note: IDLE’s
editor window doesn’t show line numbers, but it
displays the current cursor location at the bottom-
right corner; use it to locate the erroneous line in a
long source code;
• the name of the error and a short explanation
• Sandbox allows Python code to be run in an Internet browser.
• The Sandbox interface consists of three main parts:
• the Editor window, which lets you type in your code,
• the Console window, which lets you see the output of your
programs,
• a tool named the Action Buttons bar, which lets you run your
code, refresh the editor window,
• and the Settings button, which lets you adjust display settings
and switch between Python/C/C++ environments.

Sandbox
Sandbox
Terima Kasih

You might also like