You are on page 1of 44

Introduction to Computer

Science
About me
About you Kahoot
Part 1 – Introduction
to Programming
What is Programming?
The process of preparing an instructional program for a
device.
Or in simpler words,
Attempting to get a computer to complete a specific task
without making mistakes.
Cooking Example

Your friend with zero cooking


Dish to bake cookbook recipe
experience
Computer Example

Your computer Program to create Computer Algorithm


Computer A sequence of simple steps, together with a flow of control
Algorithm that specifies when each step to be executed.
How to create a computer Algorithm?

•To create a computer


algorithm, we need a
programming language.
Programming Languages

• Suited for different kinds of applications


• Low-level vs High-level
Programming
Language
Each programming language has a set of
rules you must follow when writing code,
just like in real language.
In programming this is called syntax. (like
grammar in a real-life language)
Python programming language

• High-level
• General-purpose
• Interpreted (vs compiled)
Integrated Development Environments
(IDE’s)
•A place to write and run computer
programs.
Example IDEs

IDLE

Replit
IDE Features
• Detects syntax errors
• Auto-fill
• And much more
Replit (Browser based IDE)

• Throughout this course we will use Replit to do homework and projects


Replit IDE
The ‘Run’ Button executes the
Python Code

Console showing the


Text Editor where you
output after running
write Python code
the Python Code
Shows all the
files you
have. ‘.py’ is
extension for
a Python file.
Course Summary

In this course, we will learn about how to write computer programs that
solve problems.
If you want to succeed in this course:
Reading the material is NOT enough
Most important is practice writing code
Part 2 – Introduction
to Python
Python’s basics

•Print Statement is a command that prints text to the console


Print Command

•Note: Without a print statement your program will NOT show anything in the
console:

VS
Simple arithmetic
Addition, Subtraction, Multiplication and Division
Modulus

Allows us to get the remainder of the divisional operation


Modulus cont.

• Can be used to determine if a number is even or odd. How?


Strings

• Another way of saying text


• Enclosed by quotation marks (Single or Double quotes)
String concatenation

• Adding strings together


Game score Example
4 vs ‘4’
Variables
• Something that can store information
• Can be referenced and manipulated
Variables (Cont.)

• Each Variable has a type, a name and a piece of information stored inside
of it

name
Primitive Variable Types

• Integers
• Float
• Strings
• Boolean
Integer (int)
• Can store integer value
• (-2,147,483,648 through 2,147,483,647)
• Cannot hold decimal value
Boolean (bool)
Can store values True or False
Float
Stores real numbers with decimal places
String
• Stores text
• Useful for
• Displaying text
• Storing input information
• Outputting information in a readable format
Name Variable example

1. Store the value inside of the ‘name’ variable ‘player name’


2. Prints the value of the ‘name’ variable
Name Variable example 2

1. Prompt the user for their name ‘touraj’


2. Store the value inside of the ‘name’ variable
3. Prints the value of the ‘name’ variable
Why variables
are useful?
• By Creating a variable, you can store
information in that variable and
then reference, add to, or modify it
How to define a variable
x = 10
When this statement is executed, the computer creates a little space in memory that stores
your variable name and its contents

10

x
Warehouse vs computer memory

x
How to change a variable
age = 17

age = 18
Other ways of manipulating variables

• Integer and Float variables can be


• Added
• Subtracted
• Multiplied
• Divided
• Modulused

• String variables can be


• Added
Naming conventions of variables
• Variable names must be one continuous string
• Variable names are case-sensitive (Julie and julie are different)
• Most programmers name variables according to camelCase
References
• Introduction to Programming and Computer Science - Full Course (
https://youtu.be/zOjov-2OZ0E)

You might also like