0% found this document useful (0 votes)
2 views41 pages

CH1 - Introduction To Python

Uploaded by

娜莹 金
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)
2 views41 pages

CH1 - Introduction To Python

Uploaded by

娜莹 金
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

Open-source SW & Python programming

<CH 1>

Youn Kyu Lee


Brief Bio
▪ Education
– Ph.D. in CS from University of Southern California in 2017 (Advisor: Prof. Nenad Medvidovic)
– B.S. and M.E. in CS from Korea University in 2010 and 2012, respectively (Advisor: Prof. Hoh Peter In)

▪ Work Experience
– Associate Professor at Chung-Ang University (2025~)
– Assistant Professor at Hongik University (2021~2025)
– Assistant Professor at Seoul Women’s University (2020~2021)
– Staff Researcher at Samsung Advanced Institute of Technology (2018 ~2020)

▪ Awards & Grants


– Best AI Paper Award, ICTC, 2024
– Best Paper Award, ICTC, 2022
– Best Paper Award, IEEE/ACM ASE, 2017
– Viterbi Fellowships, USC, 2012

-2-
Brief Bio

▪ Research Interests
– Artificial Intelligence, Deep Learning, Quantum AI
– AI Security
– Software Architecture, Software Analysis

▪ Feel Free to Contact!


– aiclasscau@[Link]
– younkyul@[Link]

-3-
Syllabus

-4-
CH 1. Introduction to Python
Program

• To make a computer perform tasks, humans need to provide it with a detailed list of
instructions.

• Program: A document that contains the instructions for the computer to execute.

-6-
Programming Language

• Natural Language: A language that we use in our daily lives.

• Programming Language: A formalized language used to communicate with computers,


which enables us to deliver commands to computers and perform desired tasks.

• Machine Language: The language understood by computers, consisting of binary codes


made up of 0s and 1s. Machine language directly operates the computer's hardware.

-7-
Python Interpreter

• The Python interpreter reads the source code line by line, converts each line into machine
language consisting of 0s and 1s, and executes it.

-8-
ChatGPT vs. Programmer

-9-
Python

• An interactive programming language developed by Guido van Rossum in 1991

- 10 -
Most Popular Programming Language

• Python started as a personal hobby project but was officially released to the internet
community in 1991, leading to active development and use worldwide.

- 11 -
Python

• Concise and Readable Syntax: Python has a concise and easy-to-read syntax. It eliminates the need for
unnecessary semicolons or parentheses, making the code more compact, and enforces indentation to
enhance readability.

• Dynamic Typing: Python is a dynamically-typed language, meaning you don't need to declare the type of a
variable in advance. The type is automatically determined at runtime.

- 12 -
Python

• Object-Oriented Programming (OOP) Support: Python supports object-oriented programming, enhancing


the modularity, reusability, and maintainability of code.

• Rich Standard Library: Python provides a rich standard library.

• Cross-Platform Support: Python works across various operating systems (Windows, macOS, Linux, etc.).

• Community and Ecosystem: Python has an active and open community, with many developers continuously
creating and sharing packages, libraries, frameworks, and more.

- 13 -
Python Library

- 14 -
How to Install Python

• To install Python, visit [Link] and select 'Python 3.12.0' from the Download
menu.

- 15 -
How to Install Python

• Make sure to check the following:

- 16 -
How to Start Python

• Find and run the 'IDLE' program from the Start menu in Windows.

- 17 -
Python Shell

• In the Python shell, when we type a command after the >>> prompt and press Enter, the
command is executed, and the result is displayed on the screen.

- 18 -
Python Shell

• In the Python shell, when we type a command after the >>> prompt and press Enter, the
command is executed, and the result is displayed on the screen.

- 19 -
Statement and print()

• A Python program consists of multiple lines of commands. A single line of command is called
a statement.

print("Hello World!")

• In this statement, we call a function named print(). A function is a collection of commands that
perform a specific task.

• The characters enclosed in double quotes ("...") or single quotes ('...') are called strings.
- "100": String
- 100: Integer

- 20 -
If You Forget the Quotation marks When Displaying a String

• If we forget to include the quotes when displaying a string, the following error will occur.

- 21 -
String Concatenation

+은 문자열에서는 접
합을 의미 합니다.

- 22 -
String Repetition

*은 반복을 의미하기
도 합니다.

- 23 -
Calculation

- 24 -
print()

• Printing multiple values

• Chulsoo, who is currently 20 years old, wants to print his name and how old he will be in 12
years, all in one line.

- 25 -
Script mode

• As the code becomes more complex, the interpreter mode becomes cumbersome.

- 26 -
Script mode

• Saving the commands in a file using a text editor, and then reading and executing the file all
at once.

- 27 -
Creating a Source File

• There is a method where you save the commands in a file using a text editor, and then read
the file to execute the commands one by one. The file containing the commands is called a
source file.

- 28 -
Creating a Source File

• From the Python shell menu, select [File] → [New File].


Let's write a program that takes the Fahrenheit temperature and converts it to Celsius.

- 29 -
Writing a Source File using IDLE

• From the Python shell menu, select [File] -> [New File].

- 30 -
Saving a Source File using IDLE

• Select the [File] -> [Save] in the text editor to save the code to a file.

- 31 -
Executing a Source File using IDLE

• To run this source file again, select the [Run] → [Run Module].

- 32 -
Executing a Source File using IDLE

- 33 -
Program

- 34 -
Variable

• A variable is a space created in the computer's memory where we can store numbers or
characters. In the diagram below, one box corresponds to a variable.

- 35 -
Variable

• In a program that outputs the sum of numbers entered by the user, space is needed to store
the numbers entered by the user. Additionally, space is required to store the sum of the
numbers.

- 36 -
Variable

• When storing a value in a variable, the = symbol is used. For example, to assign 90.0 to the
variable ftemp, you would do it like this:

- 37 -
Variable

• In the Python shell, when you enter the variable name and press Enter, the value of the
variable is displayed on the screen.

- 38 -
Practice#1: print()

• Write the source code to print the following using the print() function.

[Link]
print(" Hello, everyone. ")
print("I really like Python." )
print("9*8 is 72.")
print("Goodbye.")

- 39 -
Practice#1: print()

• Write the source code to print the following using the print() function.

Hello, everyone.
I really like Python.
9*8 is 72.
Goodbye.

- 40 -
Q&A

aiclasscau@[Link]

You might also like