CHAPTER 1 Introduction
– Computer is a machine which brought resolution in the world.
– Now a days, we can not even imagine our lives without computer, internet, mobile phone , e-mail etc.
– “Computer is an electronic machine that accept input and after processing produce output.“
– Computer depends upon Electric Power.
– Computer is the combination of hardware and software with which a task becomes very easy and errorfree.
– Hardware: Physical components of a computer system are known as Hardwares. For ex- Keyboard, CPU, Monitor, Printer etc.
– Software: These are sets of written instructions or programs which controls working of a computer system.
– In this chapter we will learn about various parts of computer and their working. Organization of Computer
– Computer works as per IPO Cycle (inputàprocessàoutput).
– Computer proceeses a certain input and provides a specific output. – Computer system consists of various components- like –
– CPU (ALU, Registers, Control Unit), Memory, input unit, output unit, Storage unit etc. ALU Control Registers Memory Input Unit Output Unit Storage Unit CPU Input Units
– Input devices connected to a computer system makes its input unit.
– Input unit is responsibile to accept input and to convert it into computer understandable format.
– Different input devices are used for different types of input.
– Some of the input devices are as under – • Keyboard • Mouse • Microphone • Joy-stick • OMR • OBCR • Touch Pad • Track Ball • MICR • Light Pen • Scanner • Camera • Bio metric Scanners • Touch Screen Panel
Output Units– Output devices connected to a computer system makes its output unit.
– It is the responsibility of an Output unit to produce output after processing.
– Different output devices are used for different types of output.
– Some of the output devices are as under – • Monitor • Projector • Printer • Plotter • Speaker
CPU full form Central processing unit
• CPU is the main controlling and processing unit of computer where all calculations takes place.
• CPU is also known as brain of computer system because it directs, guides and controls working of computer system.
• CPU has following components-
– Arithmatic logic unit (ALU) it performs mathematical and logical calculations.
– Control unit (CU) it controls and directs every task. – Registers it is the place to store data temporarily for the purpose of correct calculation.
Memory
• Memory is often known as Primary memory.
• It is not like human memory because data stored in this memory automatically flushes out with power cut off which can not recover later. It is also known as volatile memory.
• It is the workplace of a computer system where data is to be kept on temporary basis for the purpose of processing.
• Every memory location has a definite address.
• Smallest unit of memory is a bit.
– 8 bit = 1 byte
– 4 bits=1 Nibble
– 1024 byte = I Kilobyte
– 1024 Kilobyte = 1 Mega byte
– 1024 Megabyte = 1 Giga byte
– 1024 Gigabyte = 1 Terra byte
– 1024 Terra byte = 1 Peta byte
– 1024 Petabyte = 1 Exabyte
– 1024 Exabyte = 1 Zetta byte The total time taken to access data from memory is called Memory Access Time Types of Memory
• Main Memory is divided into two types- – RAM (Random Access Memory) – ROM (Read Only Memory)
• The memory which is in direct contact of CPU is known as primary memory. RAM and ROM both remains in direct contact of CPU.
• The total time taken to access Data from memory is known as Memory Access Time.
RAM
• In RAM, any memory cell can be accessed from any desiring memory location.
• The connection between memory and its environment is established by data input, output lines, address lines, control lines which is used to direct transfer. Block diagram of RAM is as under-
• The only limitation of RAM is that it is volatile in nature. • RAM is of two types- – Dynamic RAM (DRAM)
– Static RAM (SRAM)
• It is not possible to imagine processing without RAM.
• The efficiency of RAM depends upon the size (capacity)of RAM.
• RAM supports both read and write operations.
DRAM
• DRAM is basically consists of transistor and capacitor which stores electric charge.
• As per switching of Transistor, capacitor does contain a charge (1 bit ) or does not contain a charge(0 bit).
• Now a days, memory access time of DRAM chip is from 20 to 70 nanoseconds.
• Storage density of DRAM is from 10 to 100 Giga bits.
• DRAM needs to be refreshed again and again which is a tedious job for processor.
SRAM
• SRAM is made up of internal Flip-Flops where 1 Flip-Flop is capable of storing 1 bit. • It occupies more space as compared to DRAM.
• It is fast as compared to DRAM.
• SRAM is expensive as compared to DRAM.
ROM
• As its name implies, this memory is only for read operations.
• It is programmed at the time of hardware setting and whatever we store in this memory can not change later.
• ROM is to be used in the situations when we know that information needs not to be changed in future.
• ROM is of following types - – ROM (Read Only Memory)
– PROM (Programmable Read Only Memory)
– EPROM (Erasable Programmable Read Only Memory)
– EEPROM(Electrically Erasable Programmable Read Only Memory) Storage Unit
• It is required to store data in computer for the purpose of processing in future.
• Because Primary memory has its own limitations, secondary storage or storage unit is very much required.
• Secondary storage is used to store large amount of data.
• Various secondary storage devices are available in market now a days –
– Hard disk (Internal/External)
– Pen drive
– CD – DVD
– Blue Ray Disks
– Memory Cards
– Magnetic
Tapes System Bus
• The group of wires used to connect main parts of Computer system is called System Bus which creates an electronic path for the transfer of data.
• System bus is used to transfer data and instructions between the various components of computer system.
• The part of System bus that carries data is called Data Bus.
• The part of System bus that carries instructions is called control bus.
• The part of System bus that carries memory address is called Address Bus.
• And the bus connected with input/output units is called I/O bus.
Mobile System Organization
• Modern Mobile Phone is like a small computer in hand.
• They have less processing power as compared to computer system.
• We can perform following tasks with a mobile phone-
– Calling.
– Photo taking with camera.
– To work on various apps by – touch screen facility.
– Watching videos. – Listening audio (songs) – Playing games etc.
• Mobile phone receives power from battery.
Mobile Processor
• It is the brain of smartphone.
• It immidiately responds on reciving a command.
• It has 2 main sub-processors- – Communication Processing Unit – It helps in making and receiving call on a mobile phone. It has a digital signal processor which works with RF Transceiver and Audio subsystem.
– Application Processing Unit (APU)
– it helps in controlling all operations of mobile phone which is used to process various applications. Another supporting unit is GPU (Graphics Processing Unit) which handles all graphical applications and visuals of mobile phone.
• Now a days, all parts of a mobile are placed on a single chip which is known as System on a chip (SoC) it redues energy consumption. Mobile Display sub-system
• It is responsibile for all tasks related to display and touch of screen. It supports the following tasks- – Display Screen – Touch Sensitive Interface – Touch Sensitive keyboard Camera sub-system
• It is based on image signal processing.
• It performs following tasks- – Instant Image Capture – High Resolution Support – Image Stabilization – Other image enhancements
Mobile system memory
• It is of 2 types-- – RAM, it is available in 2 GB, 4 GB, 6 GB, 8 GB.
– ROM, it is available in 16 GB, 32 GB, 64 GB, 128 GB. Mobile Storage • It is external storage and also known as expendable memory.
• It is available in the form of SD cards and micro SD Cards. Mobile Power Management Subsystem
• This subsystem provides power to mobile phone.
• Every mobile phone receives power from a connected battery.
• It’s power is limited.
• It is required to charge battery after a certain period of time. Software
• Software is a set of programs which is designed for a special purpose.
• Hardware can not work without software.
• It behaves like an interface between hardware and user. With it’s help, a user can give directions to a hardware.
• Software gives directions to control various operations.
• Softwares are of 2 types- – System software – Application software System Software
• Software, that controls inner operations of a computer system is called system software.
• It follows the instructions related to system and facilitates the smooth working of system.
• It is not possible to work without system software.
• It works as an interface between hardware and application software.
• It is further divided into 2 parts - – Operating system – Language processor Operating System
• It is an interface between hardware and user.
• It is like a manager of whole computer system.
• It controls all resources of hardware.
• It manages various application softwares with hardware.
• It develops an environment for the user where user can give commands and can receive outputs.
Types of OS are –
– Single User OS
– Multi User OS
– Time Sharing OS
– Real Time OS
– Multiprocessing OS
– Distributed OS
Language Processor
• It is a special software which translates source code to object code or machine code.
• Source code is a group of instructions written by programmer using some computer programming language.
• Object code are those instructions which are received by translating source code in to machine code.
• They are used in the development of Software.
• Language Processor are of 3 types-
– Assembler
– Interpreter
– Compiler
Application Software
• These are the softwares designed for some specific tasks.
• These are to be installed after installation of OS only.
• OS provides environment to run an Application software.
• These are designed for a specific purpose.
• They are divided into 4 categories- – Packages (MS-Office) – Utilities (Text Editor, Paint Brush, Disk Defragmenter, Antivirus
Python (a Computer Language)
As we know that in order to communicate with a computer system, we need a language. This language may be C, C++, Java, Python or any other computer language. Here we will discuss PYTHON.
• Python was developed by Guido Van Rossum in 1991 when he was working with National Research Institute of Mathematics and Science in Netherland.
• Python was named from a comedy series “Monty Python’s Flying Circus” telecasted on BBC.
• Python can be used as OOL and POL. Python (a Computer Language) Python (a Computer Language) • Actually, Python is inspired by two languages - 1. ABC language which was an optional language of BASIC language. 2. Modula-3
• Python is very easy learning language as most of its syntax seems to be like in English.
• It is possible to get desired output in minimum instructions.
• It’s an Interpreted language.
• It’s a complete language in itself and it is very easy to download and install.
• It is a platform independent and portable language.
• It is Free Open Source. Python (a Computer Language)
• It is possible to develop various Apps with Python like– • GUI Apps • Web Apps • Games • DBMS Apps • Scripting etc.
Python (a Computer Language) LimitationsThere are few limitations in Python which can be neglected because of its vast usage.
• It is not a Fast Language.
• Libraries are very less.
• It is week in Type binding.
• It is not easy to convert in some other language.
•Python can be downloaded from www.python.org.
•It is available in two versions- • Python 2.x • Python 3.x •We will download 3.6.5 here.
•Open www.python.org on any browser.
We can work in Python in two ways-
•Interactive Mode • Script Mode
• Both have their own style of working.
• Interactive mode works like a Command Interpreter as Shell Prompt works in DOS Prompt or Linux..
• ( >>>) we can execute any instruction of Python with this.
• We can run a complete program by writing in Script mode.
Python Introduction
• In order to provide an input, process it and to receive output, we need to write a program.
• Program, is a group of instructions which controls processing.
• In other words, base for processing is ‘the Program’.
• In this chapter we will come to know about various element of processing like – character set, token, expressions, statements, input.
Python Character Set
• Character Set-is a group of letters or signs which are specific to a language.
• Character set includes letter, sign, number, symbol.
– Letters: A-Z, a-z
– Digits: 0-9
– Special Symbols: _, +, -, *, /, (, ), {, } . . . Etc.
– White Spaces: blank space, tab, carriage return, newline, formfeed etc.
– Other characters: Python can process all characters of ASCII and UNICODE.
Tokens
• Token- is the smallest unit of any programming language. It is also known as Lexical Unit.
Types of token are
i. Keywords ii. Identifiers (Names) iii. Literals iv. Operators v. Punctuators
Keywords
• Keywords are those words which provides a special meaning to interpreter.
• These are reserved for specific functioning.
• These can not be used as identifiers, variable name or any other purpose.
• Available keywords in Python are False, True, None, and, as, assert, async, await, def, del, elif, else, break, class, continue, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with and yield.
Identifiers
• These are building blocks of a program and are used to give names to different parts/blocks of a program like - variable, objects, classes, functions.
• An identifier may be a combination of letters and numbers.
• An identifier must begin with an alphabet or an underscore( _ ).
Subsequent letters may be numbers(0-9).
• Python is case sensitive.
Uppercase characters are distinct from lowercase characters (P and p are different for interpreter).
• Length of an Identifier is unlimited.
• Keywords can not be used as an identifier.
• Space and special symbols are not permitted in an identifier name except an underscore( _ ) sign.
• Some valid identifiers are – – Myfile, Date9_7_17, Z2T0Z9, _DS, _CHK FILE13.
• Some invald identifiers are – – DATA-REC, 29COLOR, break, My.File.
Literals / Values
• Literals are often called Constant Values.
• Python permits following types of literals - – String literals - “Bajrang” – Numeric literals – 10, 13.5, 3+5i – Boolean literals – True or False – Special Literal None – Literal collections
String Literals
• String Literal is a sequence of characters that can be a combination of letters, numbers and special symbols, enclosed in quotation marks, single, double or triple(“ “ or ‘ ‘ or “’ ‘”).
• In python, string is of 2 types- – Single line string
• Text = “Hello World” or Text = ‘Hello World’
– Multi line string • Text = ‘hello\ or Text = ‘’’hello world’ word ‘’’
Numeric Literals
• Numeric values can be of three types -
– int (signed integers)
• Decimal Integer Literals – 10, 17, 210 etc.
• Octal Integer Literals - 0o17, 0o217 etc.
• Hexadecimal Integer Literals – 0x14, 0x2A4, 0xABD etc.
– float ( floating point real value)
• Fractional Form – 2.0, 17.5 -13.5, -.00015 etc.
• Exponent Form - -1.7E+8, .25E-4 etc.
– complex (complex numbers) • 3+5i etc.
Boolean Literals
• It can contain either of only two values – True or False A= True B=False
Special Literals
• None, which means nothing (no value). X = None
Operators
• An Operator is a symbol that trigger some action when applied to identifier (s)/ operand (s)
• Therefore, an operator requires operand (s) to compute upon. example : c = a + b Here, a, b, c are operands and operators are = and + which are performing differently.
Types of Operators
• Python supports following types of operators -
– Unary Operator
• Unary plus (+)
• Unary Minus (-)
• Bitwise complement (~)
• Logical Negation (not)
– Binary Operator
• Arithmetic operator (+, -, *, /, %, **, //)
• Relational Operator(, =, ==, != )
• Logical Operator (and, or)
• Assigment Operator (=, /=, +=, -=, *=, %=, **=, //=)
• Bitwise Operator (& bitwise and, ^ bitwise xor, | bitwise or)
• Shift operator (> shift right)
• Identity Operator (is, is not)
• Membership Operator (in, not in)
Punctuators
• In Python, punctuators are used to construct the program and to make balance between instructions and statements. Punctuators have their own syntactic and semantic significance.
• Python has following Punctuators - ‘ , ” , #, \, (, ), [, ], {, }, @. ,, :, .. `, =
A Python Program Structure
• As we have seen in previous slides, a program contains following compnents-
– Expressions like a+b, a>b etc.
– Statements like a=10, c=a+b etc.
– Comments, lines starting with #.
– Function, block starting with def keyword
– Blocks and indentation like if and else blocks