0% found this document useful (0 votes)
18 views

W1-Introduction_03042025

The document outlines a course on Digital Computer Concepts and Practices, taught by Jaeyoung Do, focusing on fundamental programming concepts using Python. It includes details about the instructor's background, course structure, evaluation criteria, and important dates. The course emphasizes problem-solving, algorithm design, and real-world applications, with a strong focus on academic integrity and individual project work.

Uploaded by

guswls2082
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

W1-Introduction_03042025

The document outlines a course on Digital Computer Concepts and Practices, taught by Jaeyoung Do, focusing on fundamental programming concepts using Python. It includes details about the instructor's background, course structure, evaluation criteria, and important dates. The course emphasizes problem-solving, algorithm design, and real-world applications, with a strong focus on academic integrity and individual project work.

Uploaded by

guswls2082
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Digital Computer Concept and Practice

ECE 035.001

W1 - Introduction
Jaeyoung Do
[email protected]

The lecture slides were prepared based on Introduction to Computer Science


Using Python by Dierbach. © 2013 John Wiley & Sons.
About Instructor
2003.03 ~ 2007.09 B.S.: KAIST, Computer Sciences

2007.09 ~ 2012.12 M.S., Ph.D.: UW-Madison, Computer Sciences

2012.12 ~ 2014.02 Research Engineer: Microsoft Data Lab

2014.03 ~ 2016.09 Senior Scientist: Microsoft Jim Gray Systems Lab (GSL)

2016.10 ~ 2021.02 Senior Researcher: Microsoft Research (MSR)

2021.02 ~ 2023.11 Senior Applied Scientist: Amazon Alexa AI

[email protected]
2024.02 ~ Current Assistant Professor: Seoul National Univ. ECE & IPAI
https://aidas.snu.ac.kr

2
Research Interests
• Conducting innovative research on AI (LLM) technology from the
perspectives of Algorithm, Data-oriented Systems, and Application.

Healthcare
CoreAI

Question Big data


+ systems
SysAI
Answer

Manufacturing
VerAI

3
In this course…
• Fundamental Programming Concepts – Students will learn the basics of
programming using Python, including variables, control structures,
functions, and data structures.

• Problem-Solving and Algorithm Design – Emphasis will be placed on


developing computational thinking skills, algorithmic problem-solving, and
debugging techniques.

• Real-World Applications and Software Development – Students will apply


programming concepts to real-world problems, working on projects that
reinforce software development practices.

4
People

• Instructor
– Jaeyoung Do (도재영)
[email protected]

• TAs (alphabetical order)


– Jinhyeok Kim (김진혁): [email protected]
– Woohyeon Park (박우현): [email protected]
– Geon Choi (최건): [email protected]

5
Textbook

6
Evaluation

• Attendance: 5%
• Programming Projects: 20% (2 projects, 10% per project)
• Midterm Exam: 25%
• Final Exam: 35%
• Quiz & Assignments: 15%

7
Schedule

• W1 – Introduction • W9 – Text Files


• W2 – Data Expression • W10 – Dictionaries and Sets
• W3 – Control Structures • W11 – Object-Oriented
• W4 – Lists Programming
• W5 – Functions • W12 – Recursion
• W6 – Objects and Their Use • W13 – TBD
• W7 – Modular Design • W14 – TBD
• W8 – Midterm • W15 – Final

8
Important Dates

• Holidays
– May 6 (Tuesday): Substitute Holiday for Children's Day and
Buddha's Birthday

• Exams
– mid-term: 4/24 (Thu) 4pm – 6pm
– Final: 6/12 (Thu) 4pm – 6pm

9
Notes

• There are midterm and final projects, and both are individual
projects.

• Being late to class four times will be considered as one absence.

• Quizzes can be taken during both theory and lab sessions.

10
Python

• You will be using the Python programming language in this


course

11
Academic Integrity

• If you happen to do
– Cheating
– Plagiarism

• You will very likely get F


– And your mis-conduct will be reported to the student council
– Do NOT ask for an excuse: graduation, scholarship, etc.

12
Plagiarism
• All projects must be done individually:
– You may not copy code directly from any other source
– Plagiarism detection software will be used on all of the projects
– If you viewed another code (from books or lecture notes), you must
include a reference in your project
• Leave a comment!
– You should not share code with any other students by transmitting
completed functions to your peers
• This restriction includes—but is not limited to—electronic and hard-copy
sharing
• Both students (who showed or copied the code) will get the same penalty
– You may discuss projects together and help another student debug his
or her code; however, you cannot give the exact solution
13
Plagiarism

• Collaboration with other students must be limited to


– Discussions
– High-level pseudocode
– Assistance with debugging (only through the offering of advice)

• All such collaborations must be documented in your


source code

14
Motivation
Computing technology has changed, and is continuing to change the world.
Essentially every aspect of life has been impacted by computing. Computing
related fields in almost all areas of study are emerging.

15
What is Computer Science?
Computer science is fundamentally about computational problem solving.

Programming and computers are only tools in the field of computing. The field
has tremendous breadth and diversity. Areas of study include:

• Programming language Design • Software Engineering


• Systems Programming • Database Management / Data Mining
• Computer Architecture • Computer Networks
• Human–Computer Interaction • Computer Graphics
• Robotics • Computer Simulation
• Artificial Intelligence • Information Security

16
Computational Problem Solving
Two things that are needed to perform
computational problem solving:

• a representation that captures all the


relevant aspects of the problem

• an algorithm that solves the problem


by use of the representation

Thus, computational problem solving finds a solution within a


representation that translates into a solution for what is being represented.

17
e.g., Nobel Prize in Chemistry 2024

• Representation: Proteins fold into complex 3D structures that determine their


function. Predicting these structures from amino acid sequences is crucial for biology
and medicine.

• Algorithm: Hassabis and Jumper developed AlphaFold2, an AI model that accurately


predicts protein structures using deep learning, solving a decades-old scientific
challenge and advancing drug discovery and biotechnology.
18
Abstraction in Computing
Abstraction is intrinsic to computing and computational problem
solving.

• The concept of “1s” and “0s” in digital computing is an abstraction.


Digital information is actually represented as a high or low voltage
levels, magnetic particles oriented one of two ways, pits on an optical
disk, etc.

• Programming languages are an abstraction.


The instructions and data of a computer program is an abstract
representation of the underlying machine instructions and storage.

• Programming design involves the use of abstraction.


Programs are conceptualized as various modules that work together.

19
The Limits of
Computational Problem Solving
Once an algorithm for a given problem is developed or found, an important question is
“Can a solution to the problem be found in a reasonable amount of time?”

“But aren’t computers very fast, and getting faster all the time?”

Yes, but some problems require an amount of time to compute a solution that is
astronomical compared to the capabilities of current computing devices.

A classic problem in computer science that demonstrates this is the Traveling


Salesman problem.

20
The Traveling Salesman Problem

A salesman needs to visit a


set of cities. He wants to find
the shortest route of travel,
starting and ending at any
city for a given set of cities.
What route should he take?

The algorithm for solving this problem is a simple one. Determine the lengths of all
possible routes that can be taken, and find the shortest one – a brute force
approach. The computational issue, therefore, is for a given set of cities, how
many possible routes are there to consider?

21
If we consider a route to be a specific sequence of names of cities, then how many
permutations of that list are there?

New York, Boston, Chicago, San Francisco, Los Angeles, Atlanta

New York, Boston, Chicago, San Francisco, Atlanta, Loa Angeles

New York, Boston, Chicago, Los Angeles, San Francisco, Atlanta

etc.

Mathematically, the number of permutations for n entities is n! (n factorial).

How big a number is that for various number of cities?

22
Below are the number of permutations (and thus the number of routes) there are
for varies numbers of cities:

Ten Cities 10! 3,628, 800 (over three million)

Twenty Cities 20! 2,432,902,008,176,640,000

Fifty Cities 50! over 1064

If we assume that a computer could compute the routes of one million cities per
second:

• for twenty cities, it would take 77,000 years

• for fifty cities, it would take longer than the age of the universe!

23
Computer Algorithms
An algorithm is a finite number of clearly
described, unambiguous “doable” steps
that can be systematically followed to
produce a desired result for given input in
a finite amount of time (that is, it
eventually terminates).

The word “algorithm” is derived from the


ninth-century Arab mathematician, Al-
Khwarizmi who worked on “written
processes to achieve some goal.”

24
Computer Hardware
Computer hardware comprises the physical part of a computer system.
It includes the all-important components of the central processing unit
(CPU) and main memory. It also includes peripheral components such as
a keyboard, monitor, mouse, and printer.

25
Fundamental Hardware Components
Central processing unit (CPU) – the “brain” of a computer system.
Interprets and executes instructions.

Main memory – is where currently executing programs reside.


It is volatile, the contents are lost when the power is turned off.

Secondary memory – provides long-term storage of programs and data.


Nonvolatile, the contents are retained when power is turned off. Can be
magnetic (hard drive, SSD) or flash memory (USB drive).

Input/output devices – mouse, keyboard, monitor, printer, etc.

Buses – transfer data between components within a computer system.


System bus (between CPU and main memory)

26
27
Digital Computing: Its all About Switches

It is essential that computer hardware be reliable and error free. If the


hardware gives incorrect results, then any program run on that hardware
may give incorrect results as well.

The key to developing reliable systems is to keep the design as simple


as possible. In digital computing, all information is represented as a
series of digits, in which each digit is either “0” or “1”.

28
Operating Systems

An operating system is software that manages and interacts


with the hardware resources of a computer. It acts as the
“middle man” between the hardware and executing
application programs. For example, it controls the allocation
of memory for the various programs that may be executing
on a computer.

Because an operating system is intrinsic to the operation of


a computer, it is referred to as system software.

29
Operating systems also provide a particular user interface.

It is the operating system installed on a computer that


determines the “look and feel” of the user interface and how
the user interacts with the system, and not the particular
model computer.

30
31
Computer Software

What is computer software?


Computer software is a set of program instructions,
including related data and documentation, that can be
executed by computer. This can be in the form of instructions
on paper, or in digital form.

While system software is intrinsic to a computer system,


application software fulfills users’ needs, such as a photo-
editing program.

32
Program Debugging:
Syntax Errors vs. Semantic Errors

Program debugging is the process of finding and correcting errors


(“bugs”) in a computer program. Programming errors are inevitable
during program development.

Syntax errors are caused by invalid syntax (for example, entering prnt
instead of print).

Since a translator cannot understand instructions containing syntax


errors, translators terminate when encountering such errors indicating
where in the program the problem occurred.

33
In contrast, semantic errors (generally called logic errors ) are errors in
program logic. Such errors cannot be automatically detected, since
translators cannot understand the intent of a given computation.
Therefore, programs are not terminated when containing logic errors,
but give incorrect results.

For example, if a program computed the average of three numbers as


follows,

(num1 + num2 + num3) / 2.0

a translator would have no means of determining that the divisor should


be 3 and not 2. Computers do not understand what a program is meant
to do, they only follow the instructions given. It is up to the
programmer to detect such errors.

Program debugging is not a trivial task, and constitutes much of the


time of program development.
34
The First Actual Computer “Bug”

In 1947, engineers working on the Mark II


computer at Harvard University found a
moth stuck in one of the components,
causing the machine to malfunction. They
taped the insect in their logbook and
labeled it “first actual case of bug being
found.”

The term program “bug” (and “debugging”) has become a standard part of the
language of computer programmers. The log book, complete with the attached bug, is
on display at the Smithsonian Institution in Washington, D.C.

35
The Process of
Computational Problem Solving
Computational problem solving does not simply involve the
act of computer programming. It is a process, with
programming only one of the steps.

Before a program is written, a design for the program must


be developed. And before a design can be developed, the
problem to be solved must be well understood. Once
written, the program must be thoroughly tested.

36
Computational Problem Solving Steps

37
The Python Programming
Language
The Python Programming Language was
created by Guido van Rossum. It was first
released in the early 1990s.

Its name comes from a 1970s British


comedy sketch show called Monty
Python’s Flying Circus. (An example of
their work is The Argument Clinic).

Companies and organizations that use


Python include YouTube, Google, Yahoo
and NASA.

38
Python Philosophy
• Guido’s philosophy on programming language
ü “Python is an experiment in how much freedom programmers need. Too
much freedom and nobody can read another’s code; too little and
expressiveness is endangered.”

• Python’s design goal


ü Computer Programming for Everybody (CP4E)
Ø An easy and intuitive language just as powerful as major competitors
Ø Open source, so anyone can contribute to its development
Ø Code that is as understandable as plain English
Ø Suitability for everyday tasks, allowing for short development times

39
Python Features
• Simple Syntax
Python programs are clear and easy to read

• Interpreted Language
Python instructions can be executed interactively

• Powerful Programming Features


Can accomplish significant computation with few instructions

• Numerous Python Modules Provide Additional Capabilities

40
Release History
• First release
• Python 0.9.0 (Feb. 1991)
• Python 1.0 (Feb. 1994)
• Up to Python 1.6
• Python 2.0 (Oct. 2000)
• Up to Python 2.7
• Python 3.0 (Dec. 2008)
• Broke backward compatibility
• Current version is Python 3.13 (released in Oct. 2024)

https://www.python.org/

41
The Python Shell
Python can be executed interactively in the Python shell. In this mode,
executing Python is similar to using a calculator.

The >>> symbol is the shell prompt. Here, typing 2 + 3 at the prompt
outputs the result 5, redisplaying the prompt in wait of another instruction.

42
The Python Standard Library
The Python Standard Library is a collection of built-in modules, each
providing specific functionality beyond what is included in the “core” part
of Python.

For example, the math module provides additional mathematical functions.


The random module provides the ability to generate random numbers,
useful in programming, as we shall see.

Other Python modules are described in the Python 3 Programmers’


Reference at the end of the book.

43
Importing a Library Module

In order to utilize the capabilities of modules in a specific program, an


import statement is used as shown.

44
Because the factorial function is from the math module, the function is
called with the name of the module prepended:

e.g., math.factorial(20)

45
A Bit of Python
We introduce a bit of Python, just enough to begin writing some simple
programs.

Since all computer programs,

• input data
• process the data
• output results

We look at the notion of a variable, how to perform some simple arithmetic


calculations, and how to do simple input and output.

46
Variables
One of the most fundamental concepts in programming is that of a
variable.

A variable is “a name that is assigned to a value,” as shown below,

n = 5 variable n is assigned the value 5

Thus, whenever variable n appears in a calculation, the current value of n is


used, as in the following,

n + 20 (5 + 20) à 25

If variable n is assigned a new value, then the same expression will


produce a different result,
n = 10
n + 20 (10 + 20) à 30
47
Some Basic Arithmetic Operators
The common arithmetic operators in Python are,
+ (addition) * (multiplication) ** (exponentiation)
- (subtraction) / (division)

Addition, subtraction, and division use standard mathematical notation,


10 + 20 25 - 15 20 / 10
(Also, // for truncated division)

For multiplication and exponentiation, the asterisk (*) is used,


5 * 10 (5 times 10) 2 ** 4 (2 to the 4th power)

Multiplication is never denoted by the use of parentheses,


10 * (20 + 5) CORRECT 10(20 + 5) INCORRECT

Note that parentheses may be used to denote subexpressions.

48
Basic Input
The programs that we will write request and get information from the user.
In Python, the input function is used for this purpose,

name = input('What is your name?: ')

Characters within quotes are called strings. This particular use of a string, for
requesting input from the user, is called a prompt.

The input function displays the string on the screen to prompt the user for
input,

What is your name?: Charles

(The underline is used here to indicate the user’s input.)

49
Basic Output
The print function is used to display information on the screen in Python.
This may be used to display a message (string),
>>> print('Welcome to My First Program!')
Welcome to My First Program!

or used to output the value of a variable,


>>> n = 10
>>> print(n)
10

50
Can also display a combination of strings and variables,
>>> name = input('What is your name?: ')
What is your name?: Charles

>>> print('Hello', name)


Hello Charles

Note that a comma is used to separate the individual items being printed,
which causes a space to appear between each when displayed. Thus, the
output of the print function in this case is
Hello Charles

and not
HelloCharles

We will soon learn more about variables, operators, and input/output in


Python.

51
The IDLE Python
Development Environment (1/2)
IDLE is an integrated development environment (IDE). An IDE is a bundled
set of software tools for program development. This typically includes,

• an editor
for creating and modifying programs
• a translator
for executing programs, and
• a program debugger
for taking control of the execution of a program to aid in finding
program errors

52
The IDLE Python
Development Environment (2/2)

53
Using IDLE
In order to become familiar with writing your own Python programs using
IDLE, we will create a simple program that asks the user for their name, and
then responds with a greeting.

This program utilizes the following concepts:

➤ Creating and executing Python programs

➤ Input and print functions

54
Creating a New Python Program
To create a Python program file, select New File from the File menu in the VS
Code,

55
Now can begin entering lines of a program without them being immediately
executed, as in the Python shell.

• Note that parts of the program lines are displayed in a certain color. Since print
and input are predefined function names in Python, they are colored purple. The
strings in the program are colored green. The statement in red is a comment
statement. Comment statements are for those reading the program, and are
ignored when the program is executed.

• When finished, save the program file by selecting Save As (under the File menu)
and save in the appropriate folder with the name MyFirstProgram.py.
56
Executing a Python Program

To run a Python program, select Run Without Debugging from the Run menu

57
If you have entered the program code correctly, the program should execute
as shown

However, if you have mistyped part of the program resulting in a syntax error
(such as mistyping print), you will get an error message.

58
In such instances, you need to go back to the program window and make the
needed corrections, the re-save and re-execute the program. You may need
to go through this process a number of times until all the syntax errors have
been corrected.

59

You might also like