SlideShare a Scribd company logo
Computing: Introduction to
Python
Lesson One
• To know how to start Python IDLE and run a Python program.
• To use Python to perform calculations.
• To write simple programs that respond to user input.
• To use a textual programming language to solve a variety of
computational problems.
Learning Objective
Success Criteria
What Is Python?
Python is a programming language.
It was invented in the 1980s.
It was named after comedy group ‘Monty Python’.
• Yahoo (maps);
• Google (search engine);
• Shopzilla (shopping comparison site);
• Battlefield 2, Civilisation 4 (computer games);
• Industrial Light and Magic
(in films such as ‘The Phantom Menace’ and ‘The Mummy
Returns’);
• NASA;
• Nokia;
• Facebook, and many more.
Python is used in many universities to teach programming.
Python is used by:
Python is
easy to
learn.
Starting Python
We can use Python IDLE to create and run our Python programs.
IDLE is an acronym of Integrated Development Environment.
An Integrated Development Environment contains all the tools needed
to write, test and run computer programs.
• The window that first
appears when you
start Python IDLE is
called the Interactive
mode window.
Starting Python
• From the Interactive mode window, we can click on the File menu
item, and then select New File.
• This opens a new Script mode window.
Starting Python
• Good practice is to have instances of both Interactive and Script
mode windows open side-by-side, something like this:
On the left is the
Interactive mode
window.
On the right is
the Script mode
window.
Script
Interactive
Starting Python
• The Interactive mode window is easy to identify.
• You will always see >>> at the start of each new line.
Starting Python
Key Term
An Integrated Development Environment contains all the
tools needed to write, test and run computer programs. In
Python we use the acronym IDLE. Other programming
languages sometimes use the shorter acronym IDE for
Integrated Development Environment.
The Interactive mode gives immediate feedback to every line of code
that is entered, and is useful for testing ideas and small snippets of
code.
The Script mode allows a programmer to type in many lines of Python
code, and then save the code as a single program with a file name.
This file can be saved and run at any time. However, any inputs or
outputs of Python programs will always be shown in the Interactive
mode.
Python IDLE has two modes of running.
Hello World
• Let’s stick with the Interactive mode window for now,
and learn our first Python command: print
• print does exactly what it says: it prints information onto the
screen.
• It does not print anything onto a printer.
• There is a long established tradition in computer programming.
The first program that most programmers write is often a
“Hello World” program.
• In the Python Interactive window, type: print(“Hello World”)
and then press the Enter key on your keyboard.
Hello World
• Some important things to notice:
Always remember to use the (brackets) with print.
• We also used “quotes” because we were printing text.
• print is purple because IDLE recognises print as a Python
command.
• “Hello World” is green because it is a string of text (more on this
later).
• The printed output is usually blue.
Did you notice the different colours?
Try the print command again, but
this time type your own sentences.
For example: print(“Goodbye
Monty”)
Cool Calculations
• We can also use the Python print command to help us do
calculations.
• The important thing to remember here is that we are dealing with
numbers and not text, therefore we do not use “quotes” as before.
• Try the following print instructions now and see what happens:
Can you make up your own calculations?
Cool Calculations
• Computers often use the * symbol (asterisk) for multiplication.
• Why does Python IDLE give the answer 27? If we add 6 and 3, this
gives us 9. Then multiplying 9 by 7 gives 63, not 27!
• The reason is that Python uses BIDMAS.
Do you remember what BIDMAS means?
• Python knows to multiply the 3 and 7 first, and then add 6
afterwards.
So, 3 * 7 = 21, then we add 6 to 21 giving us 27.
Let’s look at this example once again:
Cool Calculations
Try these last examples, and see if you can figure out what
Python is doing with the numbers:
Cool Calculations
The double-slash // is rounding-
down (or “floored”) division. It
divides two values and rounds
down the answer.
The double-asterisk ** here means
5 to the power of 2.
These last ones are modulo-
division. % gives the remainder of a
division between two values.
E.g. 15 / 2 = 7
remainder 1.
Incredible Inputs
So far we’ve learned:
•How to start Python IDLE.
•How to open and run a Python program.
•How to use the print command.
•How to do calculations in Python.
Let’s find out how to do this in Python.
Type this code in the Interactive window, and then press the Enter
key:
Phew –
well
done!
Computer programs become much more interesting and useful when
they can respond to user input.
Incredible Inputs
You should have seen something like this:
• input is our next Python command. It waits for the user to type in
something, in this case we are asking the user to type in their
name.
• What happens to the name that is typed in?
• Answer: not much at the moment!
• There is something that happens though, we just can’t see it yet…
That’s my name – did
you type in your
name?
Incredible Inputs
To understand what’s going on, let’s look back at the
Python code we entered:
• name is a variable. We can think of variables
as like boxes in computer memory.
Each box has a label, and we can store
information in each box.
• In our Python code above, we have created
a new variable with the label: name
• name = input(“What is your name?”)
prints the question “What is your name” on screen,
then waits for the user to type something in.
• Whatever text they type in is then stored in the box
labelled name. Let’s see how this works…
Incredible Inputs
>>> name = input(“What is your name?”)
What is your name? Monty
>>>
“Monty”
This is what happens when we type in our Python code:
Incredible Inputs
One last thing about using print and input…
We can do so much more than just print out someone’s name.
Try out the following code in Python and see what happens:
• Take care with your typing, watch our for the commas and
quotes!
You should be able to see something like this:
Incredible Inputs
>>> print(“Hello”, name, “, how are you
today?”)
Hello Monty, how are you today?
>>>
“Monty”
“Monty”
name
Well I’m fine and
dandy, thanks for
asking!
Incredible Inputs
Let’s put all of our new knowledge and skills into action.
This time however we will be using the Script mode window:
On the left is the
Interactive mode
window.
On the right is
the Script mode
window.
Script
Interactive
Incredible Inputs
Type the following Python code into the Script mode window:
Incredible Inputs
We’ll need to save our program as follows.
•Click on File
•and then Save As …
•Give your file the name: Greetings.py
Incredible Inputs
To see your program in action, either click the F5 function key,
or click on the Run menu item and then Run Module.
Type in your answers and
see what happens:
Incredible Inputs
This is what happens when we run our Python
code:
What is your name? Monty
How are you today? not bad at all
What is your favourite food? fish and chips
Greetings Monty
I hear that you are feeling not bad at all
Maybe you need tasty fish and chips to eat?
“Monty”
“not bad”
“chips”
“not bad”
“chips”
“Monty”
name
feeling
food
name, feeling
and food are
variables
Let’s Bring It All Together
Key Term
An Integrated Development Environment contains all the
tools needed to write, test and run computer programs. In
Python we use the acronym IDLE. Other programming
languages sometimes use the shorter acronym IDE for
Integrated Development Environment.
The Interactive mode gives immediate feedback to every line of code
that is entered, and is useful for testing ideas and small snippets of
code.
The Script mode allows a programmer to type in many lines of Python
code, and then save the code as a single program with a file name.
This file can be saved and run at any time. However, any inputs or
outputs of Python programs will always be shown in the Interactive
mode.
Python IDLE has two modes of running.
Let’s Bring It All Together
Key Term
We can think of variables as like boxes. Each box has a label,
and we can store data (information) in each box. This data
can be either text or numbers, and can vary during the
running of a program. When the program ends, the boxes are
emptied of data.
Python is a ‘high level language’. This means that it is closer to human
language than it is to ‘machine code’, the language that all computer
processors understand. (Machine code is made up of binary
instructions, lots of ones and zeroes).
In order to convert our Python programs into machine code we use a
translator, which is simply another computer program. In other
words, we need a computer program to translate our computer
programs! Thinking of the chicken and the egg idea, how then did
programmers make the first translators? See if you can find out…
Pause for Thought
Rate Your Progress
Green Light: you feel fully confident with this objective
and you understand it well.
Red Light: you have understood some of the
objective and you will think about it some more later
on, perhaps asking a friend or teacher for help.
Amber Light: you have understood most of the
objective and you are happy with your progress.
Success Criteria:
•To know how to start Python IDLE and run a Python
program.
•To use Python to perform calculations.
•To write simple programs that respond to user input.
Nailing It Down
We have learned a lot today about Python IDLE, print and input.
Python is a great programming language to learn.
You can download it yourself at home for free by visiting:
https://www.python.org/downloads/
(or just search for ‘python’ using your favourite search engine).
There are also lots of free online versions of Python which are great
for learning how to code. Try out some of these links now:
• https://snakify.org/
• http://pythontutor.com/
• https://hourofpython.com/
• https://repl.it/languages/python3
Introduction to Python Lesson One-Python Easy Learning

More Related Content

PPTX
Python_Introduction&DataType.pptx
PPTX
Cs2 Ch1
PPTX
Application development with Python - Desktop application
PPTX
Mastering python lesson1
PPT
Py4 inf 01-intro
PPT
python-ppt.ppt
PPT
python-ppt.ppt
PPTX
Programming and Secure software development presentation consists of various ...
Python_Introduction&DataType.pptx
Cs2 Ch1
Application development with Python - Desktop application
Mastering python lesson1
Py4 inf 01-intro
python-ppt.ppt
python-ppt.ppt
Programming and Secure software development presentation consists of various ...

Similar to Introduction to Python Lesson One-Python Easy Learning (20)

PDF
Python programming
PPTX
Python Lesson for the beginners to understand the basic concept of python.pptx
PDF
introduction to python programming course
PPTX
Python basics
PDF
Python basic programing language for automation
PDF
ACM init() Spring 2015 Day 1
PDF
Fundamentals of python
PPTX
4_Introduction to Python Programming.pptx
PPTX
1.Basic_Syntax
PPTX
Python basic syntax
PPTX
Python Introduction
PPTX
python classes in thane
PDF
Introduction to Python Unit -1 Part .pdf
PPTX
PYTHON FEATURES.pptx
PPTX
Learning Python
PPT
py4inf-01-intro.ppt
PDF
python-160403194316.pdf
PPTX
Lecture on Fundamentals of Python Programming-1
PPTX
Python PPT.pptx
PPTX
Pythonlearn-01-Intro.pptx
Python programming
Python Lesson for the beginners to understand the basic concept of python.pptx
introduction to python programming course
Python basics
Python basic programing language for automation
ACM init() Spring 2015 Day 1
Fundamentals of python
4_Introduction to Python Programming.pptx
1.Basic_Syntax
Python basic syntax
Python Introduction
python classes in thane
Introduction to Python Unit -1 Part .pdf
PYTHON FEATURES.pptx
Learning Python
py4inf-01-intro.ppt
python-160403194316.pdf
Lecture on Fundamentals of Python Programming-1
Python PPT.pptx
Pythonlearn-01-Intro.pptx
Ad

Recently uploaded (20)

PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
Business Acumen Training GuidePresentation.pptx
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
Azure Data management Engineer project.pptx
PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Challenges and opportunities in feeding a growing population
PDF
Data Science Trends & Career Guide---ppt
PPTX
Computer network topology notes for revision
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Measurement of Afordability for Water Supply and Sanitation in Bangladesh .pptx
PPTX
Data-Driven-Credit-Card-Launch-A-Wells-Fargo-Case-Study.pptx
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
PDF
Foundation of Data Science unit number two notes
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
IB Computer Science - Internal Assessment.pptx
Business Acumen Training GuidePresentation.pptx
Clinical guidelines as a resource for EBP(1).pdf
Introduction to Knowledge Engineering Part 1
Azure Data management Engineer project.pptx
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
1_Introduction to advance data techniques.pptx
Challenges and opportunities in feeding a growing population
Data Science Trends & Career Guide---ppt
Computer network topology notes for revision
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Measurement of Afordability for Water Supply and Sanitation in Bangladesh .pptx
Data-Driven-Credit-Card-Launch-A-Wells-Fargo-Case-Study.pptx
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
Foundation of Data Science unit number two notes
Moving the Public Sector (Government) to a Digital Adoption
climate analysis of Dhaka ,Banglades.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
Introduction-to-Cloud-ComputingFinal.pptx
Ad

Introduction to Python Lesson One-Python Easy Learning

  • 2. • To know how to start Python IDLE and run a Python program. • To use Python to perform calculations. • To write simple programs that respond to user input. • To use a textual programming language to solve a variety of computational problems. Learning Objective Success Criteria
  • 3. What Is Python? Python is a programming language. It was invented in the 1980s. It was named after comedy group ‘Monty Python’. • Yahoo (maps); • Google (search engine); • Shopzilla (shopping comparison site); • Battlefield 2, Civilisation 4 (computer games); • Industrial Light and Magic (in films such as ‘The Phantom Menace’ and ‘The Mummy Returns’); • NASA; • Nokia; • Facebook, and many more. Python is used in many universities to teach programming. Python is used by: Python is easy to learn.
  • 4. Starting Python We can use Python IDLE to create and run our Python programs. IDLE is an acronym of Integrated Development Environment. An Integrated Development Environment contains all the tools needed to write, test and run computer programs. • The window that first appears when you start Python IDLE is called the Interactive mode window.
  • 5. Starting Python • From the Interactive mode window, we can click on the File menu item, and then select New File. • This opens a new Script mode window.
  • 6. Starting Python • Good practice is to have instances of both Interactive and Script mode windows open side-by-side, something like this: On the left is the Interactive mode window. On the right is the Script mode window. Script Interactive
  • 7. Starting Python • The Interactive mode window is easy to identify. • You will always see >>> at the start of each new line.
  • 8. Starting Python Key Term An Integrated Development Environment contains all the tools needed to write, test and run computer programs. In Python we use the acronym IDLE. Other programming languages sometimes use the shorter acronym IDE for Integrated Development Environment. The Interactive mode gives immediate feedback to every line of code that is entered, and is useful for testing ideas and small snippets of code. The Script mode allows a programmer to type in many lines of Python code, and then save the code as a single program with a file name. This file can be saved and run at any time. However, any inputs or outputs of Python programs will always be shown in the Interactive mode. Python IDLE has two modes of running.
  • 9. Hello World • Let’s stick with the Interactive mode window for now, and learn our first Python command: print • print does exactly what it says: it prints information onto the screen. • It does not print anything onto a printer. • There is a long established tradition in computer programming. The first program that most programmers write is often a “Hello World” program. • In the Python Interactive window, type: print(“Hello World”) and then press the Enter key on your keyboard.
  • 10. Hello World • Some important things to notice: Always remember to use the (brackets) with print. • We also used “quotes” because we were printing text. • print is purple because IDLE recognises print as a Python command. • “Hello World” is green because it is a string of text (more on this later). • The printed output is usually blue. Did you notice the different colours? Try the print command again, but this time type your own sentences. For example: print(“Goodbye Monty”)
  • 11. Cool Calculations • We can also use the Python print command to help us do calculations. • The important thing to remember here is that we are dealing with numbers and not text, therefore we do not use “quotes” as before. • Try the following print instructions now and see what happens: Can you make up your own calculations?
  • 12. Cool Calculations • Computers often use the * symbol (asterisk) for multiplication. • Why does Python IDLE give the answer 27? If we add 6 and 3, this gives us 9. Then multiplying 9 by 7 gives 63, not 27! • The reason is that Python uses BIDMAS. Do you remember what BIDMAS means? • Python knows to multiply the 3 and 7 first, and then add 6 afterwards. So, 3 * 7 = 21, then we add 6 to 21 giving us 27. Let’s look at this example once again:
  • 13. Cool Calculations Try these last examples, and see if you can figure out what Python is doing with the numbers:
  • 14. Cool Calculations The double-slash // is rounding- down (or “floored”) division. It divides two values and rounds down the answer. The double-asterisk ** here means 5 to the power of 2. These last ones are modulo- division. % gives the remainder of a division between two values. E.g. 15 / 2 = 7 remainder 1.
  • 15. Incredible Inputs So far we’ve learned: •How to start Python IDLE. •How to open and run a Python program. •How to use the print command. •How to do calculations in Python. Let’s find out how to do this in Python. Type this code in the Interactive window, and then press the Enter key: Phew – well done! Computer programs become much more interesting and useful when they can respond to user input.
  • 16. Incredible Inputs You should have seen something like this: • input is our next Python command. It waits for the user to type in something, in this case we are asking the user to type in their name. • What happens to the name that is typed in? • Answer: not much at the moment! • There is something that happens though, we just can’t see it yet… That’s my name – did you type in your name?
  • 17. Incredible Inputs To understand what’s going on, let’s look back at the Python code we entered: • name is a variable. We can think of variables as like boxes in computer memory. Each box has a label, and we can store information in each box. • In our Python code above, we have created a new variable with the label: name • name = input(“What is your name?”) prints the question “What is your name” on screen, then waits for the user to type something in. • Whatever text they type in is then stored in the box labelled name. Let’s see how this works…
  • 18. Incredible Inputs >>> name = input(“What is your name?”) What is your name? Monty >>> “Monty” This is what happens when we type in our Python code:
  • 19. Incredible Inputs One last thing about using print and input… We can do so much more than just print out someone’s name. Try out the following code in Python and see what happens: • Take care with your typing, watch our for the commas and quotes! You should be able to see something like this:
  • 20. Incredible Inputs >>> print(“Hello”, name, “, how are you today?”) Hello Monty, how are you today? >>> “Monty” “Monty” name Well I’m fine and dandy, thanks for asking!
  • 21. Incredible Inputs Let’s put all of our new knowledge and skills into action. This time however we will be using the Script mode window: On the left is the Interactive mode window. On the right is the Script mode window. Script Interactive
  • 22. Incredible Inputs Type the following Python code into the Script mode window:
  • 23. Incredible Inputs We’ll need to save our program as follows. •Click on File •and then Save As … •Give your file the name: Greetings.py
  • 24. Incredible Inputs To see your program in action, either click the F5 function key, or click on the Run menu item and then Run Module. Type in your answers and see what happens:
  • 25. Incredible Inputs This is what happens when we run our Python code: What is your name? Monty How are you today? not bad at all What is your favourite food? fish and chips Greetings Monty I hear that you are feeling not bad at all Maybe you need tasty fish and chips to eat? “Monty” “not bad” “chips” “not bad” “chips” “Monty” name feeling food name, feeling and food are variables
  • 26. Let’s Bring It All Together Key Term An Integrated Development Environment contains all the tools needed to write, test and run computer programs. In Python we use the acronym IDLE. Other programming languages sometimes use the shorter acronym IDE for Integrated Development Environment. The Interactive mode gives immediate feedback to every line of code that is entered, and is useful for testing ideas and small snippets of code. The Script mode allows a programmer to type in many lines of Python code, and then save the code as a single program with a file name. This file can be saved and run at any time. However, any inputs or outputs of Python programs will always be shown in the Interactive mode. Python IDLE has two modes of running.
  • 27. Let’s Bring It All Together Key Term We can think of variables as like boxes. Each box has a label, and we can store data (information) in each box. This data can be either text or numbers, and can vary during the running of a program. When the program ends, the boxes are emptied of data. Python is a ‘high level language’. This means that it is closer to human language than it is to ‘machine code’, the language that all computer processors understand. (Machine code is made up of binary instructions, lots of ones and zeroes). In order to convert our Python programs into machine code we use a translator, which is simply another computer program. In other words, we need a computer program to translate our computer programs! Thinking of the chicken and the egg idea, how then did programmers make the first translators? See if you can find out… Pause for Thought
  • 28. Rate Your Progress Green Light: you feel fully confident with this objective and you understand it well. Red Light: you have understood some of the objective and you will think about it some more later on, perhaps asking a friend or teacher for help. Amber Light: you have understood most of the objective and you are happy with your progress. Success Criteria: •To know how to start Python IDLE and run a Python program. •To use Python to perform calculations. •To write simple programs that respond to user input.
  • 29. Nailing It Down We have learned a lot today about Python IDLE, print and input. Python is a great programming language to learn. You can download it yourself at home for free by visiting: https://www.python.org/downloads/ (or just search for ‘python’ using your favourite search engine). There are also lots of free online versions of Python which are great for learning how to code. Try out some of these links now: • https://snakify.org/ • http://pythontutor.com/ • https://hourofpython.com/ • https://repl.it/languages/python3