1 of 35

CN 101

Lecture 1

Introduction to Programming

Nutchanon Yongsatianchot (Nut)

อาจารย์ ดร.ณัฐชนน ยงเสถียรโชติ (อ. นัท)

ynutchan@engr.tu.ac.th

2 of 35

Any prior programming experiences?

3 of 35

Official Class Website and Materials

4 of 35

5 of 35

Same Curriculum

  • Same materials
    • All materials are in english

  • Same exams

  • Same grading rubric

6 of 35

7 of 35

Same exams & grading rubric

  • Exams: 80%
    • Midterm - 35%
    • Final - 45%
  • Others: 20%
    • First half 10%: 6 Labs (1.5% each), 2 Prep (0.5% each)
    • Second half 10%: 6 Labs (1.5% each), 2 Prep (0.5% each)

Same for all.

  • All in class!
  • No homework or quizzes!!

8 of 35

First Half

Second Half

ครึ่งแรกสำคัญมาก!!

9 of 35

Practice, Practice, Practice!

“There is no magic.”

10 of 35

Exercise: Labs and Prep

  • แบบฝึกหัดทำมาเพื่อให้คุณฝึก!!
  • แบบฝึกหัดถูกสร้างมาจากง่ายไปยาก
  • ผมกับ TA จะช่วยตอบคำถาม
  • มีการเช็คชื่อทุกแลบ!!
  • แบบฝึกหัดทำมาให้ทำเสร็จภายใน 1 ชม. 30 นาที

11 of 35

Teaching Assistants (TA)

ธนิศร อภิรัตน์ไพบูลย์ (เติร์ด)

สกลรัตน์ สัตบรรย์

(กุ๊งกิ๊ง)

ณพล ธีระวัฒนวิศิษฎ์

(เฟิส)

12 of 35

Teaching Style

  • ผมจะสอนบน whiteboard
  • Slide มีไว้เพื่อเป็น reference เท่านั้น
  • มีอัดวีดีโอไว้ทุกคาบ แต่อยากให้มาเรียนกัน จะเริ่มตรงเวลา

13 of 35

Class Objectives

Know how to program

Get a good grade

14 of 35

Previous Class Statistics: 2566-2

N=66, mean = 69.8

N=33, mean = 63.0

15 of 35

Previous Class Statistics: 2567-1

N=82, mean = 65.3

ขาดสอบหรือซิ่ว

16 of 35

Previous Class Statistics: 2567-2

1st year EE

1st year TEP/TEPE

N=68, mean = 73.9

N=50, mean = 66.2

34% is F or W

2% is F or W

17 of 35

Responsibility

40% on YOU

50% on ME

10% on other profs

18 of 35

Late Policy

  • Within Class (+30 minutes): Full point
  • 2 days late: 50%
  • After 2 days: 0%.

19 of 35

AI Policy

  • You are free to use, but if I catch it, you will get 0 on that exercise.

20 of 35

Summary

  • ผมต้องการให้คุณประสบความสำเร็จ
  • ผมและTA มีหน้าที่เพื่อช่วยให้พวกคุณเข้าใจและทำได้
  • มีคำถาม ถามได้เสมอ (ไม่กัด)
  • Practice, practice, practice
  • ครึ่งแรก midterm สำคัญมาก !!!! (ต้องได้ >=20 จาก 35!!)

21 of 35

Introduction to Python Programing

22 of 35

Why learn to program?

  • Allow you to instruct computers to do tasks
  • Fun and rewarding activity
  • Learn to think computationally and scientifically
    • Think step by step
    • Learn to break down a problem into smaller subproblems
    • Learn to experiment

23 of 35

High-level Hardware

24 of 35

Understanding programming

  • Program = A sequence of instructions to do a task
  • Two requirements to understand programs:
    • know the programming language (Python)
    • Know how to use the language to solve a task

25 of 35

Python - Words and Sentences

  • Keywords: predefined words used to write program in high-level language
    • Each key word has specific meaning
  • Operators: perform operations on data
    • Example: math operators to perform arithmetic
  • Syntax: set of rules to be followed when writing program
  • Statement: individual instruction used in high-level language

26 of 35

Using Python

  • Download https://www.python.org/downloads/ and then install
  • Open command line (if window) or terminal (if mac or linux)
  • Type “python” to start interactive mode

27 of 35

Python Interactive Demo

28 of 35

Python Script Mode

  • Write a python program and save to a file as “.py”
  • Type “python file_name.py”

29 of 35

Jupyter notebook and Google Colab

  • In this class, we will be using Jupyter notebook for lecture and coding
  • Jupyter notebook: a web-based interactive computing platform
  • We will use Google Colab to host and run it.
    • Require Google account!!
    • https://colab.google/
    • Click ‘New Notebook’

30 of 35

Google Colab Interface

Python is running if green check

Click here to run the code

The output will be shown below

Click the code block to add your code

Add comment

31 of 35

Google Colab from Github

  • Goto the class github: https://github.com/yongsa-nut/TU_CN101_67-2/
  • Click the file (e.g. ‘Chapter1_Introduction_to_Python.ipynb’)
  • Locate “Open in Colab”

  • You can then save this file to your own google drive.

32 of 35

Turning off AI in Google Colab

1.

2. Uncheck it

33 of 35

Google Colab Demo

  • On phone, top right ≡, File -> ‘Save a copy in Drive’

34 of 35

The building blocks of programs

  • Input: Get data from the “outside world” - keyboard.
  • Output: Display the results on a screen.
  • Sequential execution: Perform statements one after another in the order they are encountered in the script.
  • Conditional execution: Check for certain conditions and then execute or skip a sequence of statements.
  • Repeated execution: Perform some set of statements repeatedly.
  • Reuse: Write a set of instructions once and give them a name and then reuse those instructions as needed throughout your program.

35 of 35

Input/Output/Process