CS1 Introduction to Computer Science
By Chan Loke
Programming with Python
In this lesson you will learn how to use the Python programming language to write codes.
Python is an
open source multi-platform programming language.
Python is used by NASA and Google .
There are many programming languages. These include Visual Basic, C,
C++, JAVA, and many others.
For this tutorial we will use the online Python IDE ( Integrated Development Interface)
Go to this website :
Figure 1
After you go to the website , scroll to the bottom of the screen you will see the screen in Figure 1.
Select Python and click on it.
You do not have to sign up or log in.

Figure 2
After you click “Python” you will see the three panels in Figure 2.
We are going to use the right most panel called the shell first. Just click anywhere in the dark area and
the sign in window will go away.
Now type
5 + 3 after the three dots
that looks like an arrow and hit enter.
You will see the answer 8.
(The three dots arrow is called the prompt)
Now try this typing this after the prompt and hit return
“Good Lookin”
**You can also type using single quotes ‘Good Lookin’
After you hit the return key Python display what you typed.
‘Good Lookin’ (note the single quotes after
you hit enter )
Better way is to type
print (“Good Lookin”)
this will print Good Lookin without the single quotes.
Great! You have just learned how to add 5 + 3 and display Good Lookin using Python.
So far you have learned how to write one code and have Python execute one line, but what if you have a
few more lines of codes.
So what we just did will not work.
We will use the middle panel where you will
write more than one line of codes.

Figure 2 - Now we are going to use the middle pane to write some real python codes. The middle pane is the program window. (Figure 3) First Program 1. Now let us write a first program. First you must have a problem to solve or to compute before you can write codes or a program for it. Here is the problem: Write a computer program to find a. the sum of three numbers b. the average of the three numbers c. print the results

Great we have solved it mathematically, now we need to translate the math to codes.
Number1; Number2; and Number3 are called
variables
in math which is also the same in
programming.
These variables are like baskets and are empty if you do not assign any numeric
values to them.
It’s like telling you to solve for the sum of Number1 plus Number2 and Number3
without giving you any numeric values.


You've reached the end of your free preview.
Want to read all 14 pages?
- Fall '19