0% found this document useful (0 votes)
24 views29 pages

Data Structure and Algorithms (005) Fall 2024 - Week 3

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)
24 views29 pages

Data Structure and Algorithms (005) Fall 2024 - Week 3

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/ 29

Data Structure

Fall 2024
Instructor: Prof. John Yun
Lecture: 9-12P, Wednesdays; S2-402

Department of AI  Big Data


Woosong University
Office Hours

When: Every Wednesdays from 2:00pm to 5:00pm

Where: Endicott College W19-225 (Prof. John Yun’s Office)

How: Only By Appointment via email to [email protected]

Duration: Maximum 30 minutes per student


• Features of the Python
Language
• Python Basics
• Program Execution
• Packages and Modules
Interactive Development
Features of the •
Environment (IDE)
Python Language

Week 3
Fall 2024
Python Features
 Interpreter Language
 Dynamic Typing Language
 Excellent in List handling
 Use indentation to express parent-child relationships
List

인터프리터 언어
동적 타이핑dynamic typing 언어
print result
리스트를 다루는 기능이 뛰어난 언어
들여쓰기로 주종 관계를 표현하는 언어

Example of Indentation

Example of Lists
• Features of the Python
Language
• Python Basics
• Program Execution
• Packages and Modules
• Interactive Development
Python Basics Environment (IDE)

Week 3
Fall 2024
Execution of Python Code
 Python code file will have .py file extension
 Execution example the Python program sample.py

Example 1

Example 2

Needs to be corrected to display 55 (Also displays errors)


print

Example 1

Example 2
Number Handling
Integer
Decimal

When you add an integer with a decimal, the result is a decimal


Type Casting

Example 1

Mod(ulus): Remainder when divided by 10

Example 2
Strings

Examples
Control: Loops

Example: Adding all values of A[3..N]


Conditional Statements

Example
Loop Control: Iteration 1

Start: 4, End: 10-1=9, Interval: 2

Start: 10, End: 4+1=5, Interval: -2

Example
Loop Control: Iteration 2
(a) List 1

(d) Dictionary

(b) List 2

(e) Collection

(c) Tuple

(f) Strings

Examples
Immutable and Mutable Types
Id(a): id of the variable a

Integers are immutable

Examples of Immutable Type

Lists are mutable

Examples of Mutable Type


Tuple, Dictionary, Collection, List

(a) Tuple (d) List

(b) Dictionary

No effect
(c) Collection Add 10 to the collection a

Examples
Calls by value, reference, assignment

integer integer

print value: 5 print value: 10

Relationship between input value and parameter in calling method with a value

integer
list

print result: 5
print result: [1, 2, ‘test’]

Example of a method call with immutable and mutable input types mixed
Class
Class

Constructor

Methods

Typical Structure of a Class


Class Examples
Traversable Class

(a) String Array 1

(b) List 1

(a) String Array 2

(b) List 2

Role of the keyword “in”


Example of Iterator
Node #0

Create iterator Object

Iterator Becomes simple if you use iterator

Node #0
• Features of the Python
Language
• Python Basics
• Program Execution
• Packages and Modules
• Interactive Development
Program Execution Environment (IDE)

Week 3
Fall 2024
Example: Program Execution

print (‘Class internal test’)


Test 3
print (‘Method internal test’)
Test 4
print (‘Class external test’) Test: dynamic and static variables

sample.py

Test.py
Example: Program Execution
Test 3

Test 4
Test: dynamic and static variables
Example: Program Execution

Test 3

Test 4
Test: dynamic and static variables
• Features of the Python
Language
• Python Basics
• Program Execution
• Packages and Modules
Interactive Development
Packages and •
Environment (IDE)
Modules

Week 3
Fall 2024
Package usage format and examples

1. From [module name] import *

2. From [module name] import [class name]


Example of Python Code Directory
Structure
• Features of the Python
Language
• Python Basics
• Program Execution
• Packages and Modules
Interactive • Interactive Development
Development Environment (IDE)

Environment (IDE)

Week 3
Fall 2024
PyCharm (Community Edition)

You might also like