Download presentation
Presentation is loading. Please wait.
1
Xiaojuan Cai(蔡小娟) cxj@sjtu.edu.cn Fall, 2015
Lecture 1 Introduction Xiaojuan Cai(蔡小娟) Fall, 2015
2
Before we start Pre-course questionnaire TA: Course website:
李春淼 Course website:
3
Course policy Final score = Practice: Dianxin building 4-313
Homework (20%) + PA (20%) + Lab (10%) + Final exam (50%) Practice: Dianxin building 4-313 Lab sample: percolation
4
Textbook and References
程序设计思想与方法 陆朝俊 高等教育出版社 References: [R1] Python Programming: An Introduction to Computer Science, John Zelle. [R2] How to Think Like a Computer Scientist, Allen Downey, Jeff Elkner and Chris Meyers
5
Why this course? Fundamental part of computer science
Helps you become a more intelligent user of computers It can be fun! Helps the development of problem solving skills Programmers are in great demand!
6
Have fun!
7
Objective To learn what computer scientists study and the techniques that they use. To understand computer programming languages. To begin using the Python programming language. To learn about chaotic models.
8
Roadmap What is computer science? Programming languages
Introduction to Python A chaotic model
9
Computing and computer
Computing is any goal-oriented activity requiring, benefiting from, or creating algorithmic processes. A computer is a general-purpose device that can be programmed to carry out a set of arithmetic or logical operations automatically. --- Definitions from wikipedia
10
Computing and computer
Computing can be traced back to 9th century. A first general-purpose computing device (computer) is invented by Charles Babbage, in early 19th century. A first digital programmable computer is Colossus (around 1943). “Computers are to computer science what telescopes are to astronomy.” – E. Dijkstra
11
Computers Colossus(1943), the first electronic digital programmable computing device. Picture sourced from Wikipedia. IBM’s Blue Gene/P supercomputer (2011) runs over 250,000 processors. Picture sourced from Wikipedia. In 2013, NUDT Tianhe-2 is ranked as the fastest supercomputer.
12
Computers Software (programs) rule the hardware (the physical machine). The process of creating software is called programming. Before programming, we need to design how to create (the algorithm).
13
Hardware basics CPU the heart of computers
“simple” instructions, fast speed Storage primary – also called RAM, fast but volatile secondary – permanently, NVRAM, ROM I/O device Mouse, keyboard, display, touch screen
14
Computer science It is not the study of computers! It studies “What can be computed?” Design – Analysis – Experimentation Design = algorithm Some problems are unsolvable Experimentation: some problems are intractable
15
Computer scientists Like mathematicians, they use formal languages to denote ideas. Like engineers, they design things and evaluate tradeoffs among alternatives. Like scientists, they observe the behavior of complex systems, form hypotheses, and tests.
16
Problem solving The most important skill One level: learn to program
formulate problems, think creatively about solutions, and express a solution clearly and accurately One level: learn to program Another level: learn how to use programs
17
Roadmap What is computer science? Programming languages
Introduction to Python A chaotic model
18
Programming languages
Natural language has ambiguity Programming languages: unambiguous and precise. Every structure in a pl has a precise form: syntax And it has a precise meaning: semantics.
19
Languages of computers
Machine language Computer’s language Impossible for human beings Assembly language Possible but still unnatural Still useful for designing efficient programs High level language
20
High-level to low-level
Interpreter Compiler Hybrid compiler/interpreting process
21
GCD in pseudo code function gcd(a, b) while a ≠ b
if a > b a := a - b else b := b - a return a
22
GCD in x86 machine language
23
GCD in x86 assembly language
24
GCD in C
25
GCD in Prolog
26
GCD in Scheme
27
GCD in Python def gcd(a,b): while a != b: if a > b: a = a - b else: b = b - a return a
28
Roadmap What is computer science? Programming languages
Introduction to Python A chaotic model
29
Python Designed by Guido van Rossum Predecessor:ABC
Name origin: Guido is a big fan of Monty Python's Flying Circus Here are some interesting slides from one of my students in SE352 (programming languages). Picture sourced from Wikipedia.
30
Python Python is an interpreted language “Hello World!” in Python
Command-line mode File mode “Hello World!” in Python print “Hello World!”
31
Program A program is a sequence of instructions that specifies how to perform a computation. Instructions include input, output, math, conditional execution, repetition (iteration, recursion), …
32
What is debugging Programming errors are called bugs.
The process of tracking them down and correcting them is called debugging. Errors Syntax error Semantics error: Run, but not the expected output Runtime error: Divide by zero
33
Let’s play around.
34
Roadmap What is computer science? Programming languages
Introduction to Python A chaotic model
35
Chaos and computing Two features:
For any input, returns 10 seemingly random numbers between 0 and 1. (chaotic) Very small differences in initial value can have large differences in the output. (butterfly effect) The function computed by program has the general form kx(1-x) where k is 3.9
36
Input: 0.25 Input: 0.26
37
Lessons from chaos This program has import implications.
Many phenomena in real world exhibit this kind of chaotic behavior. Butterfly effect Weather forecast Computers may give incorrect answers if there are very small errors in models or programs.
38
Summary A computer is a universal information- processing machine.
Computer science is the study of what can be computed. A computer comprises a CPU, main/secondary memory, and I/O devices. Programs are written using a programming language.
39
Summary (cont’d) Python is an interpreted language.
A Python program is a sequence of statements A mathematical model is called chaotic if very small changes in the input lead to large changes in the random results.
40
Python “优雅”、“明确”、“简单” 周丞 上海交通大学
41
Python娘 简介 父亲是吉多·范罗苏姆(Guido van Rossum) 出生于1991年。 女大十八变,已经历了
幼女期(1.X版本)和 萝莉期(2.X版本) 目前进入御姐期(3.X版本) 还在健康成长着……
42
Python娘 “优雅”、“明确”、“简单” 因为家长们不喜欢邻家男孩Perl的教育 方式
培养理念(设计哲♂学) “优雅”、“明确”、“简单” 因为家长们不喜欢邻家男孩Perl的教育 方式 “There’s More Than One Way To Do It.” (不只一种方法来做一件事。) 所以Python娘受到的教育是 “用一种方法,最好是只有一种方法来 做一件事”
43
Python娘 特点 活泼(动态语言) 灵活(“脚本语言”、“胶水语言”) 抽象思维(面向对象语言,支持函数式 编程)
优雅美丽(语法简捷和清晰)
44
BACK Python娘很傲骄,御姐状态和萝莉状 态变化很大。 (3.X版本不兼容2.X版本)
御姐是未来和希望,但是人们现在更 加喜欢萝莉。 BACK
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.