152412004
FUNDAMENTALS OF
COMPUTER PROGRAMMING
(with PYTHON)
ESOGÜ 2022-2023 SPRING
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
CHAPTER 1
Getting Started
Installing Python
IDLE
A first program
Typing things in
Getting input
Printing
Variables
Exercises
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
OBJECTIVES OF THE CHAPTER
• Having knowledge about the computer programming basics
• Getting up and running with Python, from downloading it to writing
simple programs
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
INSTALLING PYTHON
Go to [Link] and download the latest version of Python (version
3.5 as of this writing). It should be painless to install. If you have a Mac or
Linux, you may already have Python on your computer, though it may be
an older version. If it is version 2.7 or earlier, then you should install the
latest version, as many of the programs in this book will not work correctly
on older versions.
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
IDLE
IDLE is a simple integrated development environment (IDE) that comes with
Python. It’s a program that allows you to type in your programs and run them.
There are other IDEs for Python, but for now I would suggest sticking with IDLE
as it is simple to use. You can find IDLE in the Python 3.4 folder on your
computer.
When you first start IDLE, it starts up in the shell, which is an interactive
window where you can type in Python code and see the output in the same
window. I often use the shell in place of my calculator or to try out small
pieces of code. But most of the time you will want to open up a new window
and type the program in there.
Note At least on Windows, if you click on a Python file on your desktop, your
system will run the program, but not show the code, which is probably not
what you want. Instead, if you right-click on the file, there should be an option
called Edit with Idle. To edit an existing Python file, either do that or start up
IDLE and open the file through the File menu.
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
IDLE
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
A FIRST PROGRAM
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
A FIRST PROGRAM (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
A FIRST PROGRAM (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
TYPING THINGS IN
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
GETTING INPUT
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
PRINTING
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
PRINTING (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
PRINTING (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
PRINTING (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
VARIABLES
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
VARIABLES (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
VARIABLES (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
EXERCISES
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING
EXERCISES (cont.)
Rev.1 Dr. Gökhan DINDIŞ FUNDAMENTALS OF COMP. PROGRAMMING