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

CS1010S Lecture 01 - Introduction PDF

1) CS1010S is an introductory programming course that teaches Python. It covers basic concepts like procedural abstraction and data mutation as well as more advanced topics like object-oriented programming and dynamic programming. 2) Students can expect weekly lectures, recitations, tutorials, and problem sets involving coding missions and side quests through an online learning platform. Consistency is key to learning programming. 3) Assessments include a midterm test, practical exam, and final assessment. An alternative track allows delaying the practical exam and obtaining an IP grade to finish assessments in the next semester. Help is available through remedials, discussion forums, and email.

Uploaded by

Kervyn Mehta
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)
378 views

CS1010S Lecture 01 - Introduction PDF

1) CS1010S is an introductory programming course that teaches Python. It covers basic concepts like procedural abstraction and data mutation as well as more advanced topics like object-oriented programming and dynamic programming. 2) Students can expect weekly lectures, recitations, tutorials, and problem sets involving coding missions and side quests through an online learning platform. Consistency is key to learning programming. 3) Assessments include a midterm test, practical exam, and final assessment. An alternative track allows delaying the practical exam and obtaining an IP grade to finish assessments in the next semester. Help is available through remedials, discussion forums, and email.

Uploaded by

Kervyn Mehta
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/ 165

CS1010S Programming Methodology

Lecture 1
Introduction to CS1010S
and Python
14 Aug 2019
Welcome
3 things
WHY
should you take
CS1010S
WHAT
to expect in CS1010S
HOW
to learn Python
(In 15 mins)
But first… The Cast
Prof Ben Leong
Aaron Andrew Bao Bill Boyi
Tutors Nicholas Nigel
Peng
Seng
Phillmon
t Sabrina

Changda Chloe Darren E-Shin Ethan Gorden Subbash Vincent Wenjing Yi Hng Yi Zhe

Hui Hui Jao Ming Jeffrey Jen Han Jiaming Jit Wu Jolene Yihui Yixuan Yongyan Yu Hang Yuchen Zhenyan

Jonathan Jun Hao Lance Leben Linus Ziyun Yifan Branson


Bryan Nadya

Samuel
Churn Liyi
Valary Alfaro
Hian
WHY
should you take
CS1010S
WHY
are you taking

CS1010S
WHY are you taking CS1010S?
• Because I love programming.
• Because I want to learn programming.
• Because I am interested in computing.
• Bo bian, core requirement.
Biz Others
SDE 1% 7%
1%
FASS
2%

Science
49%
SoC
40%
WHY you should
take CS1010S
1. Because computers are
useful
1. Because computers are
useful
but they are dumb
They will precisely execute
every instruction given, even
bad ones
Personal Computer
What will you use to
• Write a report?

• Do accounting?
• Statistical analysis?

• Find prime numbers?


• Solve a puzzle?
When is Cheryl's Birthday?
What will you use to
• Write a report?

• Do accounting?
• Statistical analysis?

• Find prime numbers?


• Solve a puzzle?
• Scrape data from a website?
What will you use to
• Write a report?

• Do accounting?
• Statistical analysis?

• Find prime numbers?


• Solve a puzzle?
• Scrape data from a website?
Do cool stuff
“ You wouldn't believe what I have to
do for my first task (at work)...
Write some Python programme to
automate some data processing.
Hahahaha.
Who would have thought!

Mill Jianprasert
NUS B.B.A

Management Associate, Garena
Help simplify your
work
CS1010S vs COS2000
Programming Methodology Computational Thinking for
Scientists
ü Computational Biology üLife Science
ü Data Science Analytics üPhysics
ü Math, Applied Math, QF
üPharmacy
ü Statistics
üChemistry
Belongs to a family of üFood Science
CS1101S, CS1010, CS1010E,
etc.
CS1010S vs COS2000

Culinary Degree vs Cooking Class


Why should you take CS1010S
1. Because computers are useful
2. Because pain is good for you
WHAT
to expect in CS1010S
Work.
A lot of
work.
A lot of
hard work.
A lot of
hard work.
and some fun :)
Lectures
LT26
Recitations
Start next week
Tutorials
Start in week 3
Weekly Schedule
Classes Assignments
Mon
Tue
Wed Lectures Lecture
Thu Training
Recitations
Fri
Tutorial
Sat Training
Sun
Mon
Tutorials
Tue
Tutorial Balloting
Allocation
Do NOT use ModReg
Fill in preferences in Survey
Make sure no clashes!
You will be responsible if you end up without a class due to timetable clash

Recitation registration per norm on ModReg


Important Dates
• Wed 2 Oct: Midterm Test (7 pm)
• Fri 11 Oct: Makeup Midterm (7 pm)

• Sat 16 Nov: Practical Exam (12-6 pm)


• Fri 22 Nov: Makeup Practical Exam (2 pm)

• Please any schedule early


Google Calendar

https://calendar.google.com/calendar/ical/0eqa645n5o9cc8t1idjjlludss%40
group.calendar.google.com/public/basic.ics
No textbook
Save money
The trick:
Consistency
The problem:
Staying consistent is
HARD
“better world
gaming can make a

- Jane McGonigal
17 Mar 2010
https://coursemology.org
7 Problem Sets
15 Main Missions
+ Side quests & Contests
+ 24/7 Grading
+ Unlock Achievements
+ Badges
+ Leaderboard
COMPLETE
+XP
MISSION
COMPLETE
+XP
MISSION

COMPLETE
SIDEQUESTS
COMPLETE
+XP WIN CONTESTS
MISSION

COMPLETE
SIDEQUESTS
COMPLETE
+XP WIN CONTESTS
MISSION
ATTEND
COMPLETE TUTORIALS
SIDEQUESTS
COMPLETE
+XP WIN CONTESTS
MISSION
ATTEND
COMPLETE TUTORIALS
SIDEQUESTS
POST ON
FORUM
(Reflections)
ENOUGH XP?
LEVEL UP!
Lectures

Trainings
Exams Finish by Friday

Forums Recitations

Side-quests Tutorials
+ Trainings

Contests
Missions
Blended Learning
• Online resources on Coursemology
- Video lectures, tutorials and recitations
- Trainings, Missions and Side Quests

• Personalized Timeline (OTOT)


- Faster do, faster finish (tasks open earlier)
- If slow how?
Online Pilot Scheme
• 200 students will do fully online classes
- Recitation groups 19-22
- Tutorials will be online (schedule TBC)
- Tried and tested in CS1010X
• Personalized Timeline
- Fast pace à no issue
- Slower pace à delay exam until next semester
Alternate Assessments
Option to delay PE and Final Assessment
- Decide latest by week 10
- Class will carry on into next semester
Regular

Choose Final Assessment


Take PE and
Regular track: Regular lectures and classes Alt. final. Obtain
Midterm Test grade for
Online track: Video lectures and online classes Regular CS10101S
Take PE and
IP Grade for Sem 1 final. Obtain
Enrolled into Sem 2* grade for
Slower paced online classes Alt. CS10101S

Wk 1 Semester 1 Wk 10 Semester 2 Wk R

*possibly reduce workload computation to 2 MC for second semester


Assessment Weightage
Regular Final Alternative Final
Coursemology 25% 25%
Participation 5% 5%
Midterm Test 15% –
Practical Exam 15% 20%
Final Assessment 40% 50%
The Theory of Aiming

PASS
The Theory of Aiming

PASS
Not to worry.
Help is always
available
Remedial
TBA
Technical Issues?
Email Us
[email protected]
Need Help?
Discussion Forum
Do Subscribe
CS1010S Road Map
Memoization Searching & Sorting
ADVANCED
Dynamic Object-Oriented
Programming Programming

INTERMEDIATE
Higher-Order List Multiple
Procedures Processing Representations

BASIC
Procedural Data
Iteration Mutation &
Abstraction Abstraction
State
Wishful Recursion
Order of
Thinking Growth
Fundamental concepts of computer programming
Bust some Myths
Myth 1
“Not everyone can learn to
program”
Myth 1
“Not everyone can learn to
program algebra”
Myth 2
“I have no programming
experience. How to survive?”
Michael Yong
Year 2
Google Intern

USD7k a month
Myth 3
“I'm a girl, how can you
expect me to program?”
http://slatestarcodex.com/2017/08/07/contra-grant-on-exaggerated-differences/
Myth 4
“The bell-curve will save me.”
Grade-less
35

30

25

20

15

10

0
<20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100

2013 2014
35

30

25

20

15

10

0
<20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100

2013 2014
Myth 5
“No one will bother if I copy
my friend/senior’s code.”
Caught plagiarizing

1. Zero marks for affected Missions


2. Removal of S/U privilege
*Seniors sharing code will be considered to be
abetting in plagiarism
Plagiarism
The act of presenting another’s work or idea
that as your own.
Plagiarism #1
Direct copying

.py .py
Plagiarism #2
“Referencing”

.py

.py .py
Plagiarism #3
“Discussion”
.py

.py
.py
Not Plagiarism
Discussion (the proper way)
.py

.py .py .py


Not Plagiarism
Assistance
.py
.py

.py
Why should you take CS1010S
1. Because computers are useful
2. Because pain is good for you
3. Because coding is the new literacy
Well… not really
What are we teaching you?
What are you learning?
Python?
Not quite.
Python is just the tool
Critical Thinking
Problem Solving
Programming Methodology
Foundations of
programming
HOW
to learn Python
(In 15 mins)
IDLE

http://www.python.org
Python 2
vs
Python 3
Python 3.7.4
for CS1010S
Why Python
• Clear and readable syntax
• Intuitive
• Natural expression
• Powerful
• Popular & Relevant
Example: PayPal
• ASF XML Serialization
- C++ à 1580 lines
- Python à 130 lines
https://www.paypal-engineering.com/2014/12/10/10-myths-of-enterprise-python/
Simplicity
Futile to Teach a
Language
Here today, gone tomorrow
Computational
Thinking
What is a program?
• A sequence of instructions
• That modifies some state (of the computer)
What is a program?
Example:
1. Pick up the crate
2. Move 5 meters
3. Turn right
4. Move 5 meters
5. Put down the crate
What is the state
being modified?
Python program
a = 1
b = 2
c = a + b
if c < 0:
print('Yes')
else:
print('No')
Solve problems
• Suppose you have to program an oven to bake
bread
Idea
• Bake at 375°F for 30-35 minutes or until
golden brown and bread sounds hollow
when tapped.
Implementation?
1. Start timer
2. Measure temperature
3. If temp < 375°F then turn on heating element
4. If temp > 375°F then turn off heating element
5. If timer < 35 mins go back to step 2
Elements of
Programming
1. Primitives
• Numbers:
4 , 7/2 , 428.3

• Operators:
+ , - , * , /

• Symbols:
a , pi , foo
2. Means of
Combination
5 + 3 8
((5 + 3)-(2 * 3)) 2
3. Means of
Abstraction
7 + 6 13
a = 3

a + 6 9
4. Controlling Logic
If the light is red,
stop.
Else if it is amber,
accelerate.
Else,
proceed with caution.
While you are hungry,
eat a spoonful of rice.
Burp.
Variables
• Start with 'a'-'z' or 'A'-'Z' or '_'
• Contain only alphanumeric characters or '_'
• Case sensitive

Ian_Lee != ian_lee
Variables
• Avoid reserved keywords e.g. if
• Python convention: lower case letters separated
by '_'
•e.g. count_change
• Store memory addresses
Types
int 8 45 1234
float 2.3 3.14159
bool True False
str "cs1010s"
'cs1010s'
None
Type(…)
>>> type(123)
<class 'int'>

>>> type('123')
<class 'str'>

>>> type(None)
<class 'None'>
Type conversion
>>> str(123)
'123'

>>> float('45.2')
45.2

>>> int(23.8)
23

>>> int('cs1010s')
ValueError!
Assignment
>>> abc = 18
>>> my_string = 'This is my string'
>>> x, y = 1, 2
id1: int
variable address 18
abc id1 id2: str
“This is my string”
my_string id2
id3: int
x id3 1
y id4 id4: int
2
Operators
Arithmetic: + - * / ** // %
>>> a = 2 * 3
>>> a
6

>>> 2 ** 3
8
Operators
Arithmetic: + - * / ** // %
>>> 11 / 3
3.6666666666666665

>>> 11 // 3
3

>>> 11 % 3
2
Truth Values
Statements can be either True or False
2 > 1 is True
5 < 3 is False
Operators
Comparison: > >= < <= == !=
>>> 1 <= 10
True
>>> 5 > 15
False
>>> 5 <= 5
True
Operators
Comparison: > >= < <= == !=
>>> 2 != 3
True
>>> '1' == 1
False
>>> False == False
True
Operators
Logic: or and not
>>> True or False
True
>>> True and False
False
>>> not False
True
Operators
Logic: or and not
a or b True if either a or b is True
a and b True if both a and b are True
not a True if a is not True
Truth Tables
OR True False AND True False
True True True True True False
False True False False False False

NOT
True False
False True
Truth Value Revisted
• Python has keywords True and False
• In Python 3.x, True and False will be equal to
1 and 0
• Anything that is not 0 or empty will be
evaluated as True
Operators
Logic: or and not
>>> True and 0
0
>>> not 'abc'
False
>>> 1 or 0
1
Strings
>>> s = 'ba' >>> 'z' in t
>>> t = 'ck' False
>>> s + t
>>> 'bananb' > t
'back'
True
>>> t = s + 'na' * 2
>>> 'banan' <= t
>>> t
True
'banana'
>>> 'c' < t
False
String Slicing
• A String is a sequence of characters
• We can index a string, i.e.
>>> s = 'abcd'
>>> s[0]
'a'
>>> s[2]
'c'
• First character is 0
String Slicing
s[start:stop:step]

non-inclusive
>>> s = 'abcdef'
>>> s[0:2] >>> s[1:5:3]
'ab' 'be'
>>> s[1:2] >>> s[::2]
'b' 'ace'
>>> s[:2]
'ab'
Conditional
if <expr>:
statement(s)

e.g.
>>> a = 3
>>> if a > 0:
indentation print('Good')

'Good'
Conditional
if <expr>: e.g.
statement(s) >>> a = 3
else: >>> if a > 0:
statement(s) print('yes')
else:
print('no')

'yes'
Conditional
if <expr>: e.g.
statement(s) >>> a = -3
elif <expr>: >>> if a > 0:
statements(s) print('yes')
elif a == 0:
else:
print('no')
statement(s) else:
print('huh')

'huh'
Conditional
if <expr>: e.g.
>>> a = 4
statement(s)
>>> if a > 0:
elif <expr>: print('yes')
statements(s) elif a == 0:
elif <expr>: print('no')
elif a == 4:
statements(s) print('ahh')
else: else:
statement(s) print('huh')

'yes'
Conditional
while <expr>: >>> a = 0
statement(s) >>> while a < 5:
a = a + 1
print(a)

1
2
3
4
5
Python
in 15 mins
Am I now a
programmer?
What does it take to
be a programmer?
Do you know
1. how to read?
2. how to form words?
3. how to write sentences?

If you answered YES to all,


surely you must be a poet
What does it take to
be a poet?
What does it take to
be a programmer?
To be programmer
1. Know the elements of programming
2. Know the grammar of programs
3. Able to read and understand programs
4. Must write working programs
This step is
not trivial
Learning Outcomes
At the end of the course, you should be able to:
• describe the output of a basic program
• write a basic program to solve a given problem
Learning
how to
Learn
Feeling
Overwhelmed?
Questions?
Ways to earn XP
Survey +100 XP
before 20 Aug
Training +100 XP
By Friday
+ 50 XP
otherwise
See you next week

You might also like