Week 1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

COMP 150 – Intro.

to Programming

Faisal Naeem, PhD


University of the Fraser Valley
Computer Information Systems Department

http://www.ufv.ca/cis/

January 4, 2024
About — Dr. Faisal Naeem

Experience:
• Senior Machine Learning Research
Engineer, ReMI ( 2022 - 2023)
• Postdoctoral Research Fellow, ReMI ( 2022 -
2023)
• PhD., NUCES-FAST (Sep. 2018 - Aug. 2021)

2 January 4, 2024 Winter, 2024


Administrative Details

• Lectures – Blended: mix of in-person and online


• Lecture Notes (published on Blackboard Learn)
• Lecture Notes (published prior to classes).
• Office Hours – Email instructor for appointments (using Faisal.naeem@ufv.ca).
Please ensure your subject is of the form ’COMP 150 ON[x] - [INSERT YOUR SUBJECT]’; where
’x’ corresponds to your session index.
• Labs – These will hold (for each class) at the last 1.5 hours of the scheduled meeting times.
• Activity for the lab will be made available on the day of class, via the course page on blackboard.
• 100 points for completed labs during the lab time.
• partial points may be allotted according to the rules in the syllabus.
• Quizzes - (would be announced in advance – ONLINE).

3 September 15, 2020 Fall, 2020


Instructor’s Expectations

Let us all:

• be professional, when asking questions in


class, email, interacting with one another;

• NOT participate or abet academic


misconduct;

• attend classes and labs – talk to class mates


when you are away and be attentive;

• (where possible), please turn off your mobile


phone;

• participate during – discussions, activities,


group project; and

• ask questions or clarifications as often as


needed.

4 September 15, 2020 Fall, 2020


Definition of Programming language

• Definition: A programming language is a computer language that is used by programmers (developers) to


communicate with computers. It is a set of instructions written in any specific language ( C, C++, Java,
Python) to perform a specific task.

• Objective: Communicate the desired actions to the computer.

5 September 15, 2020 Fall, 2020


Why Programming Matters for Students

•Unlocking Problem-Solving Skills


• Programming enhances critical thinking and problem-solving abilities.

•Preparing for Future Careers


• In-demand skill across various industries.
• Opens doors to exciting and well-paying opportunities.

•Real-World Example:

• Industry Demand: Companies in tech, automotive, healthcare, and more actively seek
programmers with expertise in areas like face recognition, autonomous driving, and artificial
intelligence.

6 September 15, 2020 Fall, 2020


Course Objectives

After completing this course, you will be able to


write:

• cohesive computer programs;


• well-documented and effective program code; and
• program to solve a variety of problems, using various constructs supported by the taught
programming language (in our case - Python).

7 September 15, 2020 Fall, 2020


Course Objectives

PROBLEM
SOLVING

PRACTICE
8 6.00
01
LEC
TUR
E1

KNOWLEDGE PROGRAMMING
OF CONCEPTS SKILL
FAST PACED COURSE

 Position yourself to succeed!


 New to programming? PRACTICE. PRACTICE? PRACTICE!
9
◦ can’t passively absorb programming6.00 as a skill
01
◦ download code before lecture and LEC
TUR
E1
follow along
◦ do practice exercises
◦ don’t be afraid to try out Python commands!
Topics to be covered!

• Part 1: Elements of Programming • Part 4: Elementary Data Structures


• Variables, Assignment, Operations, • Using built-in data structures (e.g., lists,
built-in-types of data... strings, dictionaries, etc.) for storing and
• Part 2: Structured Programming manipulating data.
• Control flow structures (e.g., if-statements, • Part 5: Algorithms
for-loop, while-loop).
• More about algorithms: recursion, basic
• Part 3: Functions and Modules
sorting and searching algorithms.
• Modular programming - idea of breaking a
program into sub-programs that can be
independently debugged, maintained, and
re-used.

10 September 15, 2020 Fall, 2020


Textbooks

• ”Python for Everybody: Exploring Data Using


Python 3” by C.R. Severance
• ”Think Python: How to think like a Computer
Scientist, 2nd Ed - Version 2.4.0” by A.B. Downey
et al.
• 2nd Edition - Version 2.4.0
• Learning with Python 3 (RLE)
• An interactive edition of the book. (very useful)

1 September 15, 2020 Fall, 2020


Course info: Marking Scheme

12 September 15, 2020 Fall, 2020


Grading Policy

13 September 15, 2020 Fall, 2020


WHAT DOES A COMPUTER DO

 Fundamentally:
◦ performs calculations
a billion calculations per second!
1
4 ◦ remembers results 6.00
01
LEC
TUR
100s of gigabytes of storage! E 1
 What kinds of calculations?
◦ built-in to the language
◦ ones that you define as the programmer
 computers only know what you tell them
TYPES OF KNOWLEDGE

 declarative knowledge is statements of fact.


 Saying what you want

1 6.00
5 01
 imperative knowledge is a recipe or
TUR “how-to achieve it”.
LEC
E1
WHAT IS A RECIPE

1) sequence of simple steps


2) flow of control process that specifies when each step
is executed
3)16 a means of determining when to6.00
01
stop
LEC
TUR
E1

1+2+3 = an algorithm!
STORED PROGRAM COMPUTER

 sequence of instructions stored inside computer


◦ built from predefined set of primitive instructions
1) arithmetic and logic
1
7 2) simple tests 6.00
01
LEC
3) moving data TUR
E1

 special program (interpreter) executes each


instruction in order
◦ use tests to change flow of control through
sequence
◦ stop when done
CREATING RECIPES

 a programming language provides a set of primitive


operations
 expressions are complex but legal combinations of primitives in a
programming
1
language 6.00
8 01
LEC
 expressions and computations have values
TUR and meanings in a
E1
programming language
Programming Basics

 code or source code: The sequence of instructions in a program.

 syntax: The set of legal structures and commands that can


be used in a particular programming language.

 output: The messages printed to the user by a program.

 console: The text box onto which output is printed.


 Some source code editors pop up the console as an external
window,
and others contain their own console window.

1
Python High Level Programming Language

 Python is instead directly interpreted into machine


instructions.

interpret
source code byte code output
Hello.java Hello.class

source code output


Hello.py

2
ASPECTS OF LANGUAGES

 primitive constructs
◦ English: words
◦ programming language: numbers, strings,
simple operators
2 6.00
1 01
LEC
TUR
E1

Word Cloud copyright Michael Twardos, All Right Reserved. This content is excluded from our Word Cloud copyright unknown, All Right Reserved.
Creative Commons license. For more information, see https://ocw.mit.edu/help/faq-fair-use/. This content is excluded from our Creative
Commons license. For more information, see
https://ocw.mit.edu/help/faq-fair-use/.
ASPECTS OF LANGUAGES

 Syntax
◦ English: "cat dog boy"  not syntactically valid
"cat hugs boy"  syntactically valid
◦ programming language: "hi"5  not syntactically valid
3.2*5  syntactically valid
2 6.00
 Logic
2
errors 01
LEC
TUR
E1

 Runtime
print(1/0)
WHERE THINGS GO WRONG

 syntactic errors
◦ common and easily caught
 static semantic errors
◦ some languages check for these before running program
◦23can cause unpredictable behavior 6.00
01
LEC
TUR
E1
 no semantic errors but different meaning than what
programmer intended
◦ program crashes, stops running
◦ program runs forever
◦ program gives an answer but different than expected
Practice examples

2 6.00
4 01
LEC
TUR
E1
Class activity Quiz
PYTHON INSTALLATION

https://www.jetbrains.com/pycharm/download/?section=windows
2 6.00
6 01
LEC
TUR
E1
PYTHON FIRST PROGRAM

print("Hello, World!“)
Syntax Errors
Print["Hello, World!“]
Runtime
2
7 Errors 6.00
01
LEC
TUR
E1
Print (1/0)

Logic Errors
# Convert Fahrenheit to Celsius
print("Fahrenheit 35 is Celsius degree ")
print(5 / 9 * 35 - 32)
PYTHON DATA TYPES

Integer
Float
2 6.00
String8 01
LEC
TUR
E1
Boolean
PRACTICE EXERICE

2 6.00
9 01
LEC
TUR
E1
Studying for this course!

Success tips:

• Make possible effort to attend classes and


laboratory sessions;

• Solve problems everywhere (including your


homes);

• Read lecture notes, books and solve


problems – in the exercises;

• Practice! Practice!! Practice!!! - no shortcut


to success;

• Learning to program is an incremental


process
– dont move to the next topic if you dont
understand the present topic.

30 September 15, 2020 Fall, 2020


Questions?

31 September 15, 2020 Fall, 2020

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy