0% found this document useful (0 votes)
5 views40 pages

Topic 2 - Getting Started With Python

This document provides an introduction to programming with Python, focusing on getting started with an Integrated Development Environment (IDE). It covers the installation and use of Python IDEs, specifically IDLE and PyCharm, and discusses the features, benefits, and drawbacks of each. Additionally, it addresses common programming errors, the importance of help resources, and outlines the learning outcomes for students.

Uploaded by

Adrian Msendema
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)
5 views40 pages

Topic 2 - Getting Started With Python

This document provides an introduction to programming with Python, focusing on getting started with an Integrated Development Environment (IDE). It covers the installation and use of Python IDEs, specifically IDLE and PyCharm, and discusses the features, benefits, and drawbacks of each. Additionally, it addresses common programming errors, the importance of help resources, and outlines the learning outcomes for students.

Uploaded by

Adrian Msendema
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

Introduction to programming with Python

Topic 2:
Getting started with Python

© NCC Education Limited


Introduction to Programming with Python Topic 2- 2.2

The Unit Roadmap


• Lesson 1 - Introduction
• Lesson 2 - Getting Started with Python
• Lesson 3 - Introduction to data types and sequential programming
• Lesson 4 - Making decisions: selection statements
• Lesson 5 - Performing repetitive tasks: Loops
• Lesson 6 - Dealing with Errors
• Lesson 7 - Programming with Strings
• Lesson 8 - List
• Lesson 9 - Modularity
• Lesson 10 - Object Oriented Programming
• Lesson 11 - Storing Data in Files
• Lesson 12 - Summary and Assignment preparation
Introduction to Programming with Python Topic 2- 2.3

What’ve We Learnt From Last Lesson

• What is a computer instruction?


• What are the TWO (2) main types of
programming languages?
• Explain the TWO (2) types of low-level code.
• State the SIX(6) stages of Software
Development Lifecycle.
Introduction to Programming with Python Topic 2- 2.4

What Is This Lesson About?

• In this lesson, you will learn how an IDE is used to


write high-level program code. This will include
installing a Python IDE and how to interact with
Python using both a command line and a GUI.
• You will also learn how to use the help functions
and where to get help with writing program code
and errors that arise.
Introduction to Programming with Python Topic 2- 2.5

Scope and Coverage

This topic will cover:


• Installing and using the IDE
• Installing Python
• Interacting with Python
• Command line
• GUI
• Help
Introduction to Programming with Python Topic 2- 2.6

Learning Outcomes

By the end of this topic students will be able to:


• Describe the purpose of, features and tools of an IDE
• Install an IDE for Python
• Interact with the IDE for Python
• Use the command line for Python
• Use the GUI for Python
• Access help functions
Introduction to Programming with Python Topic 2- 2.7

IDE

• Integrated Development Environment


• Software that:
– Has an editor where you can write program code
– Helps you write program code, for example it may provide auto-
complete, auto-correct and auto-indent features
– Has error detection tools, for example identifies syntax errors by
underlining them, displays the line numbers with a description of
errors
– One or more translators to convert and execute your code
Introduction to Programming with Python Topic 2- 2.8

Choosing an IDE

• There are many different IDEs for all languages


including Python
• Each IDE has benefits and drawbacks

• Two IDEs for Python are IDLE and PyCharm


Introduction to Programming with Python Topic 2- 2.9

IDLE vs PyCharm

IDLE PyCharm
Free of cost for full functionality Free as open-source, but fee paid for full
functionality
Not as resource heavy – can use on most Resource heavy – requires reasonable
computers memory e.g. 8GB RAM
Easier to use for simple coding Requires more setting-up before you can
start
Few tools and options Many options and debugging tools
Few debugging tools Multiple debugging tools
Introduction to Programming with Python Topic 2-
2.10

Task

• Find the names of one other IDE for Python.


• Identify the features of the IDE.
• Identify the benefits of the IDE.
• Identify the drawbacks of the IDE.
Introduction to Programming with Python Topic 2-
2.11

Why IDLE?

• In this topic you will learn how to install and use IDLE.
• This is because:
• It is free to access
• It is less memory intensive
• It contains what you need to get started.
• This does not mean it is the best IDE for you.
• There is no right or wrong choice. It is up to you to decide
which to use.
• Your centre might have installed an IDE already for you to
use.
Introduction to Programming with Python Topic 2-
2.12

Installing IDLE and Python

• IDLE is free to download from: [Link]


• Click on Downloads and then if you are running Windows, on the right-hand side
of the menu click on the button to download.
• If you are running a different platform, select it from the menu and follow the
instructions.
Introduction to Programming with Python Topic 2-
2.13

Installing IDLE and Python


You will then be asked to download and save a
file.

Once you have downloaded the file, you can run it


and follow the instructions to install the software.
Introduction to Programming with Python Topic 2-
2.14

Path Setup

• You will be asked if you want to install a PATH for


Python.
• The PATH allows your operating system to locate
the Python executable when needed.
• Select to install the PATH when given the option.
• This allows your OS to run Python no matter where
you save your Python files.
Introduction to Programming with Python Topic 2-
2.15

Checkpoint Summary

• IDE stands for Integrated Development


Environment.
• An IDE is used to write a program in a high-level
language.
• IDEs provide tools for example translators, editors
and debugging tools.
• There are lots of different IDEs you can use. Each
one has benefits and drawbacks.
Introduction to Programming with Python Topic 2-
2.16

Interacting with Python using IDLE

• IDLE has two windows.


• The first one that opens
is the Shell.
• You can type code
directly in here and run
it.
• If you write your code as
a program, the output
will be shown here.
Introduction to Programming with Python Topic 2-
2.17

Command Line Interface

• A command line is where you type the code and run it


directly.
• In IDLE this is where you type the code into the Shell.
• One line of code is entered,
for example print(“Hello”).
• The line is run directly.
Introduction to Programming with Python Topic 2-
2.18

Interacting with Python using IDLE


• Click on the menu File and then New to create a new untitled document.
• You type your code into this window.
• You need to save your file (in a sensible folder) before you can run your
code.
• This is a Graphical User Interface, it has additional features such as
colour coding.
• A program is created and saved before the code runs.
Introduction to Programming with Python Topic 2-
2.19

Interacting with Python using IDLE

• This is an example showing the code and Shell


window side by side.
• The code is on the right, the Shell showing the
output is on the left.
Introduction to Programming with Python Topic 2-
2.20

Interacting with Python using IDLE


• You will notice that IDLE has different colour
text.
• Purple is used for reserved words. These are
functions and commands that Python uses.
For example: print and input.
• Green is for strings. Strings are contained within
speech marks "This is a string“.
• Black is for variables and other characters, such
as arithmetic operators and brackets.
Introduction to Programming with Python Topic 2-
2.21

Interacting with Python using IDLE

• This shows the purple text is print and input


• The green has the strings
• The black is the variable name, the = and
brackets
Introduction to Programming with Python Topic 2-
2.22

Translator

• The translator most commonly used for Python


is an interpreter.
• An interpreter converts one line of Python code
and then runs it.
• The interpreter then moves on to the next line.

Translate Execute Translate Execute


line 1 line 1 line 2 line 2
Introduction to Programming with Python Topic 2-
2.23

Interpreter

• The interpreter will stop running when it finds a


syntax error (the rules of the programming
language have been broken).
• The code will run and produce an output up to that
line, then you will get an error message.
Introduction to Programming with Python Topic 2-
2.24

Errors
• Errors are ok! Everyone makes errors in
programming, even people who have been
doing it for years. Errors are not a problem,
what you do about them is important.
• You will need to work out what the error is
and try and fix it.
• You might not fix it the first time, but you can
run the code again and see what happens
this time.
Introduction to Programming with Python Topic 2-
2.25

Types of Error

• There are 3 types of error you might encounter:


• Syntax
• Logic
• Run-time
Introduction to Programming with Python Topic 2-
2.26

Syntax Error

• This is where the code does not meet the rules


of the programming language.
• Each language has rules for the grammar and
structure that it must follow, you will learn about
these throughout this unit.
• Examples could be incorrect spelling, missing a
keyword or missing a bracket.
Introduction to Programming with Python Topic 2-
2.27

Syntax
• In this example the code (on the right) has == on
line 4, this should be =
• The left-hand side shows how the error is
displayed. It gives you the line number and what it
thinks the error is.
Introduction to Programming with Python Topic 2-
2.28

Logic Error

• The program runs and does not produce an


error. However, the output is not what you were
expecting.
Introduction to Programming with Python Topic 2-
2.29

Logic Error Example


• In this example 200 is output instead of the
expected 30. This is because * is used instead
of +
Introduction to Programming with Python Topic 2-
2.30

Run-time Error

• This is when the program is running and tries to


do something that it cannot do.
• Common examples including trying to divide by
0 and running of memory.
Introduction to Programming with Python Topic 2-
2.31

Run-time Error Example


• In this example the program has tried to divide
100 by 0. The code started to run and then
stopped when it found this error.
Introduction to Programming with Python Topic 2-
2.32

Help

• There is lots of help available, from within your IDE,


online and other resources.
• In IDLE there is a Help menu at the top. Click on
this button and you can select Python docs.
Introduction to Programming with Python Topic 2-
2.33

Help

• The page that


opens has links
to several
different options.
• There is a tutorial
and reference to
the libraries
available.
Introduction to Programming with Python Topic 2-
2.34

Help
• The Internet is a great source of help when it comes
to programming.
• Any problem you encounter, many other people
have likely encountered as well.
• Using a suitable search engine you can find
websites with example code, that include tutorials
and forums where you can ask questions.
• The Python website is always a good place to start.
Introduction to Programming with Python Topic 2-
2.35

Help

• There are lots of textbooks about programming


in general and Python.
• A couple of examples are found on the
references slide but there are many more.
Introduction to Programming with Python Topic 2-
2.36

Quiz

1. What does IDE stand for?


2. What is the purpose of an IDE?
3. Identify TWO (2) features found in an IDE?
4. What is the name of a Python IDE?
5. Why are THREE (3) reasons you chose the IDE you are
using?
6. What is a PATH and why is it important?
7. Where can you get help with your programming?
Introduction to Programming with Python Topic 2-
2.37

Topic Summary

• An IDE is an Integrated Development Environment


• IDEs have tools to help you write, run and debug your
program for example an editor
• Python has lots of different IDEs
• Each IDE has its benefits and drawbacks
• Python uses an interpreter, one line is translated and then
executed before moving onto the next line
Introduction to Programming with Python Topic 2-
2.38

What’s Next?

In the next lesson we will be looking at:


 Introduction to variables
 Assignment statements
 Introduction to data types
 Arithmetic operations
 Dates and Times
 Comments
 Writing a program using sequential statements
Introduction to Programming with Python Topic 2-
2.39

References

• CGP Books (2022). Python programming guide. Coordination Group


Publications Ltd
• Python (2023). Python. Available at: [Link] (Accessed 25th
July 2023)
• PyCharm (2023). Install Python. Available at
[Link] (Accessed
25th July 2023)
• Robbins, P. (2023). Python Programming for Beginners. Independently
published.
• W3 Schools. (2023). Python Tutorial. Available at
[Link] (Accessed 25th July 2023)
Topic 2 – Getting started with Python

Any Questions?

You might also like