Introduction and Lesson 1
Introduction and Lesson 1
➢
Course overview
➢
Syllabus
➢
General Introduction to Programming Languages
➢
Programming Environments
Course Overview
➢At the end of the course you’ll have a basic grasp of programming – enabling you to
write simple programs in Python as well as prepare you for further study in
programming languages.
2
Syllabus
3
Syllabus
4
Syllabus
5
Lesson 1: Welcome to Python!
➢
Lesson Overview
➢
What is Python?
➢
Introduction to IDE & IDLE
➢
Python Programming In IDLE
➢
Writing your first Program
➢
Review
What is Python?
●
Developed by Guido van Rossum
higher-level language that enables
●
●
How can a python program be understood by a
computer?
●Compilers and Interpreters.
7
What is Python?
●
Compilers and Interpreters.
●Compiler:- translates the entire program into
an executable file that can be saved and
distributed to end-users.
●
C++, Java, C# are compiled languages.
●Interpreter:- translates the high-level code,
one line at a time, as the program runs.
●
Python is an Interpreted language. Other
languages like JavaScript also use
interpreters.
8
Introducing IDE’s and IDLE
➔
IDE stands for Integrated Development
Environment.
➔ IDE is a program that enables you to both write and run your
Python code within a single application.
➔
In Python, one such environment is called IDLE.
➔There are other IDE’s for Python such as Jupyter, PyCharm, Spyder etc. They
might offer different features but do not affect the basics working of Python.
You can use which ever you like – for the sake of this course we will stick with
IDLE.
IDLE – is clean, simple, and fairly easy to work with, just like Python.
➔
9
Introducing IDE’s and IDLE
➔
Python and IDLE are already installed on the lab
computers.
➔You can download and install it on your personal PC by going to
https://www.python.org/downloads/
➔
To start IDLE – Go to Start and Type IDLE and click on
it.
10
Getting started with IDLE
➔
Open IDLE, and you’ll see a
window with three greater than
signs (>>>). This is the
interpreter prompt.
➔
You can use this window to type
your Python statements at the
prompt and have them
immediately evaluated.
➔
But IDLE offer much more than
this. Look at the menu items at the
top of the window.
11
Writing Your First Program.
➔
To get some practice with this, type
the classic Hello World! program
code. Click in the blank window and
type the following:
➔ print(“Hello World”)
➔
Did you notice the color changes in the
text you typed?
➔
This is one of the nice features of IDLE’s
editor.
➔
It gives you visual cues to help with your
programs.
➔Thishelps with the readability of your code,
especially when it gets longer.
12
Writing Your First Program.
➔
The reason print turned purple is
because it's a keyword (a reserved word)
in Python.
➔That means it has a special meaning, and you
won't be able to use it as a variable name.
Otherwise, Python will get confused and won't be
able to run the code.
➔
The Hello World! text turned green to
designate that the text is a literal string.
➔
In general, a string is just a collection of
letters.
➔This is a literal string because it literally displays
the phrase Hello World! on the screen.
13
Running Your First Program
➔
Now you have your very first Python
program written. Let's run it and see what
it does.
➔
You might think at this point that all you
have to do is click Run > Run Module. The
problem is that Python requires that you
save your program before running it. And
you’ll see the pop up window on the top.
➔
Click Ok and save the file. Give it a name
that’s descriptive.
➔Python will give you another dialog box that
enables you to choose the file name and where it is
to be saved.
14
Running Your First Program
➔
Python will give you another dialog box that enables
you to choose the file name and where it is to be saved.
➔
It’s a good idea to create a new folder someplace
where you'll easily find it, perhaps on the Desktop or in
your Documents folder. Then inside that folder, create a
new folder for each of our lessons in this course.
➔
If you have a flash drive, save your programs on it so
that you can easily access it anywhere.
15
Running Your First Program
> As soon as you save your file IDLE will run you code and
you will see an output like the one in the picture below.
> Notice now how control switches back over to the original
window that you saw when you first opened IDLE.
> Going back and forth between the window where your
program source code is located and the window where your
program runs may seem strange at first, but you'll get used
to it.
16
Lesson 1 Review
17