0% found this document useful (0 votes)
7 views3 pages

Notes

Uploaded by

Alekya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Notes

Uploaded by

Alekya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer System: IPO (Input Process Output Cycle)

Input -----> Process -----> Output

CPU
ALU: for arithemtic and logical part
CU: Co-ordination Part

Storage: used to store program


1. On behlaf of accessibility by CPU
1.1 Primary Memory: A memory that is directly accessible to CPU is called primary
memory
e.g.RAM, ROM, cache
1.2 Secondary memory: A memory that is not directly accessible to CPU is called
secondary memory
e.g. HDD, SSD, Pen Drive, CD, DVD, Blu-ray disk, Memory card etc.

2. On behlaf of content retention capacity w.r.t. power supply


2.1 Volatile memory: A memory whose content is lost as power supply off
e.g. RAM
2.2 Non-volatile memory: A memory whose content remain as it irrespective to
power suuply.
e.g. HDD, SSD, Pend Drive, ROM

How a program execute?


CPU <-------> Primary Storage <-----> Secondary Storage
(Process) (Program)

We are going to write code (called source code) using some high level proramming
language (may be python, java, swift, go, .net). Ultimately computer is going to
understand only one language that is binary i.e. machine code.

source code -----> Interpreter/Compiler -----> Binary

What an interpreter does?


- Interpreter is used to convert source code in the machine code line by line this
converted code is executed by the operating system.
- If any error exists in the code then interpreter will stop immediately i.e. say
we have a code of 30 line with error in line 12 & 18 so during interpretation first
time the interpreter will stop at line 12 it will ask user to make correction then
user will again interpret the program' then the interpreter will stop at line 18.
- The machine code generated by the interpreter is one time used because it is not
stored anywhere that's why if same python code is to be executed for 5 times then
it has to be interpreted for 5 times.
- The interpreter has to be in the memory whenever we want to execute source code
so interpreted languages requires more memory to execute.
- Interpreter is always slow than its counter parts i.e. compiler & assembler
- Interpreter is always secure than its counter parts because for every execution
the interpreter performs required checks.
e.g. python, java

CPP ------> Compiler -------> Binary


- Compiler is used to convert source code in the machine code all at once (not line
by line) this converted code is executed by the operating system.
- Compiler is used to report all errors in one shot.
- The machine code generated by the compiler is stored in the HDD and it can be
executed by operating system for any number of time because it is stored that's why
if same code is to be executed for 5 times then no need to recompile it again.
- The compiler is not required to be in memory for execution once the code is
already compiled i.e. compiler is memory efficient.
- compiler is always faster.
- Compiler is less secure than its counter parts because for once compilation is
done than compiler has nothing to do with execution so security checks are not
executed every time.
e.g. C, C++

Memory Units
4 GB = 4 x 1024 MB
4 GB = 4 x 1024 x 1024 KB
4 GB = 4 x 1024 x 1024 x 1024 B
4 GB = 2^2 x 2^10 x 2^10 x 2^10 B
4 GB = 2^32 B

Every memory location (of 1 byte) is identified using a physical address which is
very difficult to remember and process for human (e.g. 0xAFE2:585A)

Instead of identifying a memory location using the physical address we wanted to


get it identified using the human friendly name. To do the same we will use
variable name.

What is variable?
General Definition: A variable is a named memory location whose value can be
changed.
python specific definition: A variable is reference to memory location (called
object) that has value actually means in python programming A variable does not
store value but a variable store the location of the object such that actually the
value is available in the object.

Creating variable in python


variable-name = value

variable naming rules


1. Can be made from combination of A-Z, a-z, 0-9, special symbol (only _)
2. Cannot be started with a digit
3. cannot have comma or space
4. variable name must not be a reserved keyword
5. Convention: variable name should be meaningful
e.g.
a, abc, basic_salary, gold9, simple123_321 are valid variable names
9gold, basic salary, basic,salary, if, elif, def, 123*123 are invalid variable
names

In python programming, type function is available to check the data type of the
variable
+-+-+-+-+-+-+-
+ An Example +
+-+-+-+-+-+-+-
age = 17
print(age, type(age))
percentage = 85.25
print(percentage, type(percentage))
st_name = "Om"
print(st_name, type(st_name))
gender = 'M'
print(gender, type(gender))

Execution
stack heap
|74859658|--->|___17___| (object)
age 74859658

|74253698|--->|__85.25_| (object)
percentage 74253698

|74147859|--->|__Om_| (object)
st_name 74147859

|74268952|--->|__M_| (object)
gender 74268952

Output
8 <class 'int'>
85.25 <class 'float'>
Om <class 'str'>
M <class 'str'>

How exactly python variables are stored in the memory?


Dusing execution every process (i.e. an executing program) is going to occupy some
space in the RAM that occupied space is called address space. The address has
following parts
1. Data Segment: used to contains values and variables. The data segment further
has following parts
a. stack:
The memory occupied in the stack can be given a human friendly name
The memory allocation in the stack is very fast
The memory allocation in the stack cannot be resized
The memory allocation in the stack takes place statically
b. heap:
The memory occupied in the heap cannot be named
The memory allocation in the heap is slow
The memory allocation in the heap can be resized
The memory allocation in the heap takes place dynamically

2. Code Segment: used to contains the functions and statements

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