Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
235 views

Downloading and Installing Python

The document provides instructions for downloading and installing Python and describes how to write and run a simple Python program. It recommends downloading Python from python.org, checking the "Add Python to PATH" option during installation, and using the IDLE integrated development environment that comes with Python to write "print('Hello World')" as a first program. It also demonstrates how syntax errors appear when parts of the program are deleted or changed, and recommends using the PyCharm editor.

Uploaded by

fykk
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
235 views

Downloading and Installing Python

The document provides instructions for downloading and installing Python and describes how to write and run a simple Python program. It recommends downloading Python from python.org, checking the "Add Python to PATH" option during installation, and using the IDLE integrated development environment that comes with Python to write "print('Hello World')" as a first program. It also demonstrates how syntax errors appear when parts of the program are deleted or changed, and recommends using the PyCharm editor.

Uploaded by

fykk
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Downloading and installing

PYTHON
GO TO : https://www.python.org/downloads/

created by : Nouf Almunyif


Choose your operating system

created by : Nouf Almunyif


created by : Nouf Almunyif
Choose the suitable release

created by : Nouf Almunyif


• select Python 3
– If you're a Windows user, start the downloaded .exe file and follow all the steps.
– Leave the default settings the installer suggests for now, with one exception - look at
the checkbox named Add Python 3.x to PATH and check it.

– If you're a macOS user, a version of Python 2 may already have been preinstalled on your
computer, but since we will be working with Python 3, you will still need to download and
install the relevant .pkg file from created by : Nouf Almunyif
the Python site.
Starting your work with Python
Now that you have Python 3 installed
• To start your work, you need the following tools:
• an editor which will support you in writing the code
• a console in which you can launch your newly written code
and stop it forcibly when it gets out of control;
• the Python 3 standard installation contains an application
named IDLE.
IDLE is an acronym: Integrated Development and Learning
Environment.

created by : Nouf Almunyif


Navigate through your OS menus, find IDLE somewhere under
Python 3.x and launch it. This is what you should see:

created by : Nouf Almunyif


Python3.8.5 shell

created by : Nouf Almunyif


HOW TO WRITE AND RUN YOUR FIRST
PROGRAM

created by : Nouf Almunyif


1. create a new source file  

created by : Nouf Almunyif


2. IDLE opens a new window for you. You can
use it to write your code.

This is the Editor Window


• The editor window is currently untitled, but it's good practice to
start work by naming the source file, Click File (in the new
window), then click Save as..., select a folder for the new file and
chose a name for the new file.

Example:
Python needs its files to have the .py extension
created by : Nouf Almunyif
3. Write one line into your editor window
• The line looks like this:

4. Try to run your code

created by : Nouf Almunyif


This is the result of running your code

created by : Nouf Almunyif


How to spoil and fix your code
• Remove the closing parenthesis ) , your code contains a syntax
error now. IDLE should not let you run it.
• Try to run the program again. A new window appears – it says
that the interpreter has encountered an EOF (end-of-file)
• The editor window shows clearly where it happened.

created by : Nouf Almunyif


How to spoil and fix your code
• Let's spoil the code one more time. Remove one letter from
the word print. Run the code by pressing F5. As you can see,
Python is not able to recognize the error.

created by : Nouf Almunyif


The message (in red) shows
 the location of the error (the name of the file containing the error, line
number and module name)
* note: the number may be misleading, as Python usually shows the
place where it first notices the effects of the error, not necessarily
the error itself;
 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.

created by : Nouf Almunyif


• You may have noticed that
the error message
generated for the previous
error is quite different from
the first one.
• This is because the nature
of the error is different and
the error is discovered at
a different stage of
interpretation

created by : Nouf Almunyif


We will use a special editor

created by : Nouf Almunyif


Watch the following videos to learn how to
install and use Pycharm
• https://www.youtube.com/watch?v=WQjf5sn
eeVI

• https://www.youtube.com/watch?v=Fr71l40in
4o

created by : Nouf Almunyif

You might also like