agatsu_presentation/slides.md

4.0 KiB

class: center, middle

Introduction to Programming

Irene - Dec 24, 2022


Basics of Computers

Computers are made of three basic parts

  1. Processing
  2. Input/Output
  3. Storage

??? Start by talking about how a computer has three parts. Draw an analogy to the human body.

Draw this diagram on board to explain the interaction

-----------      ----------------         -------------
|  Input  | <--> |  Processing  |  <--->  |  Storage  |
-----------      ----------------         -------------
                       ^
                       |
                       v
                   ------------
                   | Output |
                   ------------

--

  • Processing is done by the CPU.
  • Input/Output devices are for instance: keyboard, mouse.

How do Computers Speak?

Computers use a different language than humans. Just like humans communicate in natural languages like Hindi, Kashmiri, English, etc, computers communicate in binary.

  • English: marker
  • Binary: 01101101 01100001 01110010 01101011 01100101 01110010

--

ASCII Codes

Letter Decimal Binary
A 65 01000001
a 97 01100001
B 66 01000010
b 98 01100010
. 46 00101110

How does code run?

  • Computers read a piece of code from memory.
  • Each number is a special instruction.
  • The number tells the computer what to do.
  • The computer executes this and then moves on to the next instruction.

???

Build a hypothetical machine. Create ASM for it.

0001 ADD
0010 SUB
0011 MUL
0100 DIV
0101 INP

Programming Languages

  • Early on, programs were written in binary.
  • Then to make things simpler, programs were written in Assembly.
  • And the progression continued to make higher and higher languages.

??? explain the transition

give examples of ADDR and 00101110

e.g.

01000010 01100001
ADD 0xff

--

Example code

name = input("What is your name?")
print("Welcome", name)

How do you create apps?

There are multiple languages that help us in various different tasks

--

  • General Purpose Languages are used for a variety of things

    • Python is used in Desktop Apps, Data Science, Machine Learning, Web Servers, etc.
    • JS is used for website development, backend development, etc.
    • Java is used for servers, Android Applications, etc.

--

  • Special Languages help us develop specific things.
    • HTML is used for creating content of websites.
    • CSS is used for styling webpages.
    • XML is used for storing data.

Python

Python is a general purpose programming language. It is a beginner friendly programming language. For this session, we will skip the installation but you can simply install it by downloading the setup from python.org.

We will be using an application called IDLE to run our code.

???

Open IDLE and explain how running the code works and how we can store files and run the code inside them. Introduce to some basic ideas like using interpreter as a calculator, stdout and thus print.


Memory and Variables

Memory is where our program stores data. It is different than Hard Disk as it is a temporary storage. When we write programs, we store tiny bits of data to this storage. We can access this data by variables.

*a = 100
print(a)

*b = "Jinal"
print(b)

???

Explain memory in depth. Drop into idle and run the code. Explain that we are storing data in the memory and print is the command to send it through to output


Data Types

Python has various data types. The basic data types available are:

  • Boolean
  • Integer
  • Float
  • String

???

Explain type conversion and introduce to int and float functions. Explain addition on types.


Task: Ask for two numbers and add them

--

str1 = input("Enter Number 1: ")
num1 = int(str1)

--

str2 = input("Enter Number 2: ")
num2 = int(str2)

--

total = num1 + num2
print(total)