Gebze Technical University
ENF-101 Lecture Notes
INTRODUCTION TO THE PYTHON PROGRAMMING LANGUAGE
Curriculum
1 week: Introduction to the Python Language
2 weeks: First Python Program
Three weeks: Operators
4th week: Data Types and Comparisons, Arrays
5th week: Standard Input/Output
6th week: Loops and Conditionals
7th week: Functions and Local/Global Variables
8th week: File Open/Read/Write
week 9: Libraries and Modules
week 10: Error Catching in Python
11th week: Midterm exam
12th week: Graphical User Interfaces (GUI)
week 13: Modeling and Simulation
14th week: General Review and Applications
week 15*: -
week 16*: Final Exam
2
Grading
Evaluation
Evaluation type Week number Weight (%)
Midterm exams (Visas): 8 30
Other work during the
- -
semester:
Project: 2,5,9.11 20
Homework: - -
Quiz: - -
Final exam: 16 50
Total weight: one hundred (%)
3
CONTENT This Week
Course Purpose
Computer and Software
Algorithm and Programming Languages
Python Programming Language Basics
Features and Advantages of Python
4
COMPUTER SCIENCE AND PROGRAMMING MAIN OBJECTIVE OF THE
COURSE
❑Computer Science and Programming
The main objectives of the course are:
- To write small-scale programs using numerical thinking tools, to
understand the working mechanisms of existing programs written
by others, and to teach students how to think like a computer
scientist by gaining the ability to interpret their codes.
5
OS
● The operating system is a low-level system program that
manages computer resources (CPU, memory, hard disk, other
devices) and provides communication between the user and the
computer.
Basic Tasks of the Operating System
● Central Processing Unit Management Shell
● Memory Management
● Disk Management
● File System Management
Sunflower seed
● Management of Other Devices Kernel
(Kernel)
In 1985 Windows 1.0 was released. Although
Windows source code is not publicly available, it's
been stated that its kernel is mostly written in C, with
some parts in assembly. Linux kernel development
started in 1991, and it is also written in C.
Program, Programming and Software
● A machine-compatible representation of an algorithm
is called program.
● Programs for humans are shown on paper or on the computer
screen.
● For machines, the programs are coded in accordance with the
technology of the machine.
● Development and encoding into machine compatible format
into the machine insertion process is called programming.
● Programs, and the algorithms that express collectively is
considered software. In another definition, software is a general
term that includes programming and related documentation.
Makine
Program İşlemci
Dili
Algorithm
● A set of steps that describe how to do a problem or a particular job is
called algorithm. An algorithm is a sequential, precise (explicit) set of
executable steps that describe a finite process.
● eg:
● Cooking → recipes
● Finding an address → Directions
● Laundry → Machine operating instructions
● In order for a machine (computer) to be able to solve
a particular problem or perform a task, an algorithm
must first be discovered that will enable this task to
be done.
● Then, the discovered algorithm should be expressed
as compatible with the relevant machine.
Algorithm Flow Diagrams
● Example: Telephoning algorithm flowchart:
(This shapeCagiltay,Selbes, Tokdemir and Turhan's Introduction to Programming lecture note from
Chapter 1fromtaken.)
Programming Process
Programming Process
Program
Algorithm The program is Installation
An algorithm is coded with a The compiled
Problem developed to selected program is installed
solve the programming on the computer and
problem. language. made ready for use.
Compilers (1/2)
● Converter programs whose source language is a high-level language and
whose target language is a low-level language are called compilers. A
low-level language is usually a symbolic machine language.
● Programs that translate a program written in a
particular language into machine language are
called compilers.
Compilers (2/2)
● The meaning of the purpose code, which is the
output of the compilers, may vary depending on
the operating system.
● Reloadable intent code are called relocating
object module.
● To generate code that can run on a DOS (or
Windows) operating system, binding needs another
low-level converter program called binder.
Interpreters
● Interpreters are programs that directly execute the
source program by treating it part-by-part or line-by-
line.
● Interpreters do not generate intent code.
● Interpreters are easier to write than compilers.
● Program execution time of interpreters (runtime) is
high.
● Interpreters always need source code, this is an
important issue in terms of source code
confidentiality.dezis an advantage.
● eg: vbScript, JavaScript, HTML languages interpreters
(eg: Google Chrome is an interpreter.)
Classification of Software (1/2)
● Professional and Commercial Software.
Ex:accounting, stock control and patient follow-up programs.
● Data acquisition, processing, reporting and storage are its main
features.
● The amount of data processed is relatively large.
● Most of the time is spent on I/O operations.
● Scientific and Engineering Software.
Ex: Electronic circuit solution, simulation, building beam/column
calculation programs.
● Mathematical and statistical algorithms are predominant.
● Intensely deals with numbers and sequences of numbers.
● The amount of data is relatively low.
● Mathematical complexity is its main distinguishing feature.
● CPU usage is quite high.
Classification of Software (2/2)
● Artificial intelligence software.
Ex: Chess playing programs, expert systems, natural language
detection and robot programs
Programs aimed at imitating human behavior
● Visual Software.
Ex: Game and animation programs.
● These are the programs in which image processing and
algorithms are intense.
● They make heavy use of the computer's graphical interface
● System Entries.
Ex: Operating systems, compilers, editors, communication
programs.
● It is software that gives life to computer hardware.
● They are lower level than application programs.
Classification of Programming Languages (1/3)
● Programming languages can
be classified according to
"according to their level" or
"to usage areas
● Level is a measure of the
proximity of a programming
language to human
perception.
● As the level in
languages increases, the
programmer's job becomes
easier.
● However, overall efficiency
and flexibility decreases.
Classification of Programming Languages (2/3)
(source: http://www.ias.ac.in/resonance/Dec1998/pdf/Dec1998p43-54.pdf)
Classification of Programming Languages (3/3)
● Programming languages can be listed as follows
according to their usage areas:
● Scientific and Engineering
Languages:PASCAL,Cand FORTRAN
● Database Languages: DBASE, PARADOX,
FOXPRO, SQL
● Artificial Intelligence Languages: LISP, PROLOG
● General Purpose Languages: C,PYTHON and
PASCAL
● System Programming Languages: C and
ASSEMBLY
Evaluation of Programming Languages
1. Expression Power(expressivity)
2. Data Types and Structures(Datatypes and Structures)
3. Ease of Entry/Exit(Input/Output facilities)
4. Portability(portability)
5. Sub-Programming Ability(madularity)
6. Productivity(efficiency)
7. Legibility(readability)
8. Flexibility(Flexibility)
9. Ease of Learning(pedagogy)
10. Generality(generality)
11. Structurality(Support for Structuralprogramming)
12. Article Orientation (Objectorientation)
BASICS OF THE PYTHON PROGRAMMING LANGUAGE
❑Python; It is an object-oriented, interpretable,
modular, and interactive programming language.
❑Python is a programming language that was
started to be developed in the early 90s by a Dutch
programmer Guido van Rossum. Contrary to
popular belief, the name of this programming
language does not come from the python snake.
Guido van Rossum named it after the show Monty
Python : A British comedy group called ”Monty
Python's flying circus.
20
FEATURES OF THE PYTHON PROGRAMMING
LANGUAGE
▪It is an object-oriented programming language.
▪It is free. (Free)
▪Compilable
▪It is powerful and fast.
▪The software is easy and simple.
▪Commercial applications can be developed.
21
Features of the Python Language
•Python is a high level language.
•Python is an object-oriented language.
•Python is a flexible and powerful language.
•For Python, the IDLE IDE comes with the installation. Besides,
IDEs like pycharm and netbeans can be used. It provides
convenience with its tools for debugging and writing fast code.
•It's free, open source.
•There is an extensive library use.
•It is widely used in web services, network and socket
programming and data analysis.
2
WHERE TO USE THE PYTHON PROGRAMMING LANGUAGE
▪Database Programming
▪GUI (Graphics User interface) Programming
▪Internet Programming
▪Mobile Program:eg. Android Program and Game
23
Python Installation
22.02.2024
JetBrains Pycharm Foundation
22.02.2024
Python2 and Python3
Python’s lead developer Guido van Rossum decided to do a proper fix on
2.x to put an end to the compatibility issues and bugs found in 2.x.
As a result, version 3.x has emerged.
One of the most important points to be aware of is that due to the radical
changes made in 3.Python, 2.x and 3.x do not support each other.
22.02.2024
Differences between Python2 and
Python3
Use of the print function.
Integer division differences.
Unicode differences and byte type usage.
Use of xrange() and next() functions.
Use of circular variables.
Use of input() and raw_input() functions.
Use of rounding operations.
22.02.2024
CONTENT Next Week
Python Programming Language Basics
Features and Advantages of Python
Variables in Python Language
Python Operators
Python Data Types
28