0% found this document useful (0 votes)
58 views

Chapter One

Python is a widely used programming language that can be used for web development, automation, and data analysis. It was invented in the Netherlands in the early 1990s. There are multiple versions of Python available, with the most recent being Python 3.10.2. Python code can be run using an interactive interpreter or integrated development environments like IDLE. Python uses indentation rather than braces to define code blocks and whitespace is meaningful. Key concepts include variables, data types, functions, modules and objects.

Uploaded by

Student Ritwan
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Chapter One

Python is a widely used programming language that can be used for web development, automation, and data analysis. It was invented in the Netherlands in the early 1990s. There are multiple versions of Python available, with the most recent being Python 3.10.2. Python code can be run using an interactive interpreter or integrated development environments like IDLE. Python uses indentation rather than braces to define code blocks and whitespace is meaningful. Key concepts include variables, data types, functions, modules and objects.

Uploaded by

Student Ritwan
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Chapter One:

Introduction to
Python
Prepared by: Eng
Mohamed Ahmed
Mohamed
Fundamentals of Python

 Introduction and History


 Installing & Running Python
 Running python programs
 Writing python code
Introduction to Python
 Python is a computer programming language often
used to build websites and software, automate tasks,
and conduct data analysis. Python is a general
purpose language, meaning it can be used to create
a variety of different programs and isn’t specialized
for any specific problems.

 Invented in the Netherlands, early 90s by Guido van


Rossum
Brief History of Python
 Named after Month Python
 Open sourced from the beginning but
not now
 Considered a scripting language, but is
much more
 Used by Google from the beginning
 Increasingly popular
Version of Python
 Python 3.10.2, documentation released on 14 June 2022..
 Python 3.9.7, documentation released on 30 August 2021.
 Python 3.9.1, documentation released on 8 December 2020.
 Python 3.9.0, documentation released on 5 October 2020.
 Python 3.8.1, documentation released on 18 December 2019.
 Python 3.7.3, documentation released on 25 March 2019.
 Python 3.7.2, documentation released on 24 December 2018.
 Python 3.7.1, documentation released on 20 October 2018.
 Python 3.6.4, documentation released on 19 December 2017.
 ….
 …
 Python 1.4, documentation released on 25 Octobar 1996
 Python 1.0, documentation released on 19 December 1994

 Versions from 3.9.8 to 3.10.2 cann’t use windows 7


http://docs.python.org/
Running
Python
The Python Interpreter
 Typical Python implementations offer
both an interpreter and compiler
 Interactive interface to Python with a
read print loop
>>> 7+5
12
>>>x=6
>>>y=6
>>>b=x+y

>>>’mohamed’
Print
 Python command print – Displays data, values,
and expressions

 The single and double quotation mark string


objects, which are collections of texts
surrounded by quotes.
Be familiar with Python printing
>>> print ("Hello, World! ")
Hello, World!

>>> "hello"
'hello'

>>> "world"
'world'

>>> "hello"+"world"
'helloworld'
Numbers in python
>>> a=3 #Name Created
>>> b=4
>>> a+1, a-1 # (3+1), (3-1)
(4,2)

>>> b*3, b/2


(12,2)
Complex Numbers in python

 Built into Python


 Same operations are >>> x = 3 + 2j
supported as integer >>> y = -1j
>>> x + y
and float
(3+1j)
>>> x * y
(2-3j)
Installing
 Python is pre-installed on most Unix systems,
including Linux and MAC OS X
 The pre-installed version may not be the most
recent one (2.6.2 and 3.1.1 as of Sept 09)
 Download from http://python.org/download/
 Python comes with a large library of standard
modules
 There are several options for an IDE
• IDLE – works well with Windows
• Emacs with python-mode or your favorite text editor
• Eclipse with Pydev (http://pydev.sourceforge.net/)
IDLE Development Environment
 IDLE is an Integrated Development Learning
Environment for Python, typically used on
Windows
 Multi-window text editor with syntax highlighting,
auto-completion, smart indent and other.
 Python shell with syntax highlighting.
 Integrated debugger
with stepping, persis-
tent breakpoints,
and call stack visi-
bility
Naming Rules
 Names are case sensitive and cannot start
with a number. They can contain letters,
numbers, and underscores.
bob Bob _bob _2_bob_ bob_2 BoB
 There are some reserved words:
and, assert, break, class, continue,
def, del, elif, else, except, exec,
finally, for, from, global, if,
import, in, is, lambda, not, or,
pass, print, raise, return, try,
while
Whitespace
Whitespace is meaningful in Python: especially
indentation and placement of newlines
Use a newline to end a line of code
Use \ when must go to next line prematurely
No braces {} to mark blocks of code, use
consistent indentation instead
• First line with less indentation is outside of the block
• First line with more indentation starts a nested block
Colons start of a new block in many constructs,
e.g. function definitions, then clauses
Thank you
Eng mohamed ahmed

You might also like