FUNDAMENTALS
1.1 INTRODUCTION
The programming language is the communication medium to interact with
computer. There are many programming languages in market to accomplish the
requirement. Through this communication some sort of problems are submitted to
computer to get it solved. The efficient and correct result could be attained only
when the problem submission is done with proper procedure. By keeping the above
this chapter include the content: internal working procedure of computer, problem
solving approach and end with introduction to Python programming language and
its working environment.
It is always good to know some basic information about the computer before
getting into the programming language. The fundamental concepts of computer are
given in this topic.
1.1.1 Computer Science
Computer science is a computational problem solving in which computer and
programming languages are tools to do the computation.
There are many fields of computer science like Software Engineering, Software
Testing, Database Management System, Data Mining, Information Security,
Cryptography, Graphics, Simulation, Machine Learning, Artificial Intelligent,
Operating System, Networking, Robotics, Mobile Technology, Information
Technology and Multi Media.
1.2 ESSENTIALS OF COMPUTATIONAL PROBLEM SOLVING
The essential things needed to the Computational Problem Solving are
representation of problem and algorithm steps. Representation of problem includes
the compartmentalization of all the relevant aspects of problem.
Example: The problem statement is “Simple Interest Calculation”
The representation includes
➛ Identify Terms involved – Principle Amount, Rate of Interest, Duration.
➛ Identify type of each Terms – The whole number, Fraction number.
➛ Input – Decide the terms to be assigned a value from user input.
➛ Calculation – Logic to solve the problem. Consistency of each Term in
calculation.
The algorithm steps are used to show all possible aspects to find the final solution.
1.3 COMPUTATION ALGORITHM
Algorithm is finite number of unambiguous steps which systematically followed to
find the solution of given problem in stipulated time period. It is a generalized
procedure used to solve the problem. The algorithm should be independent of
programming language used to solve the problem. It is written in simple English.
Example: Find Largest of Three Numbers
Step 1: Start
Step 2: Declare variable a, b, c
Step 3: Read value for a, b, c
Step 4: If a > b then
Step 5: If a > c then
Display a is Greatest
Go To Step 11
Step 6: Else If b > a then
Step 7: If b > c then
Display b is Greatest
Go To Step 11
Step 8: Else If c > a then
Step 9: If c > b then
Display c is Greatest
Go To Step 11
Here is the extracted text from the second image:
Step 10: Else
Display a, b, c are Equal
Step 11: stop
1.4 COMPUTER HARDWARE
The physical components of computer are called hardware. Different components
are shown in diagram:
┌────────────────────┐
│ Storage Device │
│ ✧ Hard disk │
│ ✧ SD card │
│ ✧ DVD drive │
│ ✧ CD drive │
│ ✧ USB stick │
└────────┬───────────┘
│
┌────────────┐ │ ┌────────────┐
│ Input Device│<───┼───>│Output Device│
│ ✧ Keyboard │ │ ✧ Printer │
│ ✧ Mouse │ │ ✧ Monitor │
│ ✧ OCR read │ │ ✧ Projector │
│ ✧ Graph tbl│ │ ✧ Speaker │
│ ✧ Microphone│ │ ✧ Headphone │
│ ✧ Touchscreen│ │ ✧ Tactile │
└────────────┘ └────────────┘
▲
│
┌──────────┴──────────┐
│ Central Processing │
│ Unit (CPU) │
└──────────┬──────────┘
│
┌─────────┴───────────┐
│ Communication Device│
│ ✧ Modem │
│ ✧ Bluetooth │
│ ✧ Wifi device │
│ ✧ Network card │
└─────────────────────┘
Computer Hardware
The important components of computer used for computation are
1. Central Processing Unit (CPU)
2. Main Memory
The external hardware connected with computing unit are called peripherals.
Peripherals are Categorized as
i. Input Device
ii. Output Devices
iii. Communication Devices
iv. Storage Devices
1.4.1 Central Processing Unit
Central Processing Unit (CPU) is the brain of computer containing digital logic
circuit able to interpret and execute instructions. The CPU includes Arithmetic
Logical Unit (ALU), Control Unit, and Memory Registers.
ALU is used to perform arithmetic and logical calculations. The process
controlling and instruction flow controlling activities are carried by Control Unit.
The Memory Registers in CPU are stored with processable data and result.
┌───────────────┐
│ Control unit │
└──────┬────────┘
│
┌─────────────▼─────────────┐
│ Arithmetic logic unit (ALU)│
└─────────────┬─────────────┘
│
┌───────▼────────┐
│ Memory Unit │
└────────────────┘
Figure 1.2 Central Processing Unit
The modern CPUs are Microprocessors on single Integrated Circuit (IC).
1.4.2 Main Memory
The storage location where the currently executing programs reside is called Main
Memory. The CPU can directly access main memory. It is fastest accessible
memory location. It is also called as Primary Memory.
Two categories of Main Memories are:
Read Only Memory (ROM)
The content of memory are read only. The ROM is used to start the computer are
stored in this kind of main [Link] is non volatile memory the content of
memory is permanent even when the power is turn off.
Random Access Memory (RAM)
The content of memory can be read and write at any number of time.
The programs currently in exaction are stored in this memory. It is a volatile
memory, the content in this memory get vanished when power is turn off.
1.4.3 Peripheral
The external hardware connected with CPU are called peripherals.
Some of the peripherals are discussed here.
Keyboard: It is a standard input device used to give input to system. It contain
alpha numeric keys, function keys and control keys.
Mouse: It is a input device. It gives input to computer by pointing or selecting the
content.
Monitor: It is a standard output device where the result of computation, the
selection content are shown to the user. The touch monitors are used both input and
output purpose.
Printer: It is a output device. Used to get the hard copy of content.
Hard Disk: It is a memory unit. It categorized under secondary storage device. It
is a nonvolatile memory the content in this memory are permanent even after
power turn off. It is portable memory.
Modem: The Modulation and Demodulation device used to connect the computer
with internet.
Buses: Buses are wire used to connect the computer hardware.
It carries data and control information between the components.
1.5 DIGITAL COMPUTING
The information in system are stored in digital format. In electronic computing
each digital information is in different voltage level. The hardware distinguishes
voltage level to handle the data.
Internally this information are stored only in form of 0’s and 1’s. Representing of
information only in 0’s and 1’s are called as Binary Representation. The voltage
representation of decimal numbers are;
Figure 1.4 Voltage Representation
1.5.1 Binary Number System
The number system with two digits 0 and 1 is a binary number system. The digit is
called bit (Binary Digit). Base (radix) of this number system is two. That is total
number of digits in number system. Varying number of bits are used to denote data
in computer. The number of bits represented as multiples of 2 (4, 8, 16, 32 etc.).
Group of 4 bits of binary number are called nibble. Group of 8 bits of binary
number are called byte. Group of 16 bits are called word.
Example:
The numeric value 45 represented into binary as (00101101)₂.
The number 45 divided by base of Binary Number. The remainder of each division
is written from bottom to up. The below diagram shows the conversion.
2 | 45
2 | 22 → 1
2 | 11 → 0
2|5 →1
2|2 →1
2|1 →0
→1
(00101101)₂
Decimal to Binary Conversion
The place value of each bit is 2⁰, 2¹, 2² etc.
The Binary Numbers are converted in Decimal numbers by multiplying each bit by
2 power it place value. It is shown in below diagram.
1. System Software
The computing instruction used to operate the computer is called System Software.
This software is used to control and synchronize the communication between the
components of computer. Each component and peripherals have its own system
software to attach it with computer and to communicate with each other
components. The system software of each new component connected with the
system have to be installed.
Example: Driver Software, Operating System.
2. Application Software
The computing instructions used to solve user problems are called Application
Software. The application software is developed based on user requirement.
Example: Calculator, Word Processor, Adobe Reader, Photoshop
1.7 OPERATING SYSTEM
Operating System is a System Software bridges user and Computer Hardware. It
integrates all the components of system. System Software and Application
Software running in system. It acts a middle-man between user program and all the
computer component.
Example: Window, UNIX, LINUX, Mac, iOS, Android.
Figure 1.8 Operating System as Middle Man
Roles of Operating System are:
1. Process Management
2. Memory Management
3. File Management
4. Input and Output Management
5. Security Management
Memory Management:
Allocates and manages computer memory for different programs and data,
preventing conflicts and optimizing usage.
Process Management:
Controls the execution of programs, allocating resources like CPU time and
memory to each process, and ensuring smooth multitasking.
File Management:
Organizes and manages files and directories on storage devices, providing
mechanisms for creating, deleting, accessing, and storing files.
Device Management:
Controls and coordinates the interaction between the computer and its peripheral
devices (printers, keyboards, etc.)
Security:
Protects the system from unauthorized access, viruses, and other security
threats.
Provides mechanisms for user authentication and access control.
1.8 PROGRAMMING LANGUAGE
Programming language is set of notations, keywords to form an instruction which
instruct the computer to perform specific task. The program written using
programming language are referred as Computer Code. Evolution of programming
language started from machine language to high level language. This evolution was
along with efficient hardware architecture development. Due to which the user
could able to solve many complicated programs in stipulated time.
The language to particular hardware architecture is called machine language. It is
hardware dependent. The program need to be changed to execute in another
hardware architecture. Such languages were written in form of 0’s and 1’s. These
programs can be executed faster because it is in machine understandable format.
The next level machine language is Assembly Language. It is written in mnemonic
codes. It is in form of commands.
The high level programming language is next in this evolution. It is in human
understandable form. Procedural languages and object-oriented programming
languages are two major paradigms of high-level language. These two languages
different in method of modularizing the program.
Some of the high level languages are C, C++, [Link], [Link], Python, Perl,
PHP, JAVA, etc.,
The programs have to be converted into machine understandable form to execute
and to get result. So the assembly language and high level languages need a
translator to convert the program into machine understandable form.
1.8.1 Syntax, Semantic and Translation
The communication language follow some rules to form a meaningful sentence.
The programming language rules applied to form an instruction is called syntax.
The symbols and keywords of programming languages are arranged as per syntax
to form executable instructions. Semantic is meaning associated with instruction
which is syntactically correct.
The CPU can execute the program only when the instructions are in low level (0's
and 1's format).
The programs written in high level languages need to be converted into machine
understandable form in order to execute it. The Translator is the software
associated with programming language used to convert high level into machine
language. The Compiler and Interpreter are the translators used to convert the
program into machine code.
Handwritten note:
"Two types of translation
(i) Compiler
(ii) Interpreter"
Figure 1.9 Translator
A=b+c
A=A+1
Print(A)
(High level language)
↓
Translator
(Software)
↓
10101
01010
10100
(Low level language)
The Compiler is a translator software which converts the high-level programming
instructions into machine language / it converts entire program before starting the
execution. So it will list detail of all the syntax errors flow. The program compiled
successfully without any syntax error can be executed any number of times.
Figure 1.10 Compiler Flow
A=b+c
A=A+1
Print(A)
(High level language)
↓
Compiler
(Software)
↓
10101
01010
10100
(Low level language)
↓
CPU
Handwritten note: "Direct trans"
The Interpreter is a translator software which converts the program into machine
language in instruction (one line) by instruction order. Execution of translated line
gets completed immediately before translating the next line. This is refer to
Interactive Mode. The translation and execution gets halt when a Syntax Error
identified in line being translated. The program must be interpreted for each time
of execution. The interpreter is little bit slow when compare to compiler due to the
line by line handling.
Interpreter Flow
A=b+c
A=A+1
Print(A)
(High level language)
↓
Interpreter
↓
10101 - one line
↓
CPU
The mistake in program’s syntax are called Syntax Error. The Syntax errors are
identified and reported during the translation. (The translation gets completed only
when the program is free of Syntax Error.)
The mistake exist in program’s semantic are called Semantic Error. This is also
called as Logical Error. The program with Semantic Error will produce wrong
result (output). Identifying the location and cause of Semantic Error is called
Debugging. Rectifying the Semantic Error is called Bug Fixing.
1.9 THE PROCESS OF COMPUTATIONAL PROBLEM SOLVING
The problem solving is the process involving sequence of steps. The sequence
shown in the below diagram.
Problem Analysis
↓
Program Design
↓
Program Implementation
↓
Program Testing
1.9.1 Problem Analysis
The first step in Problem Solving is Problem Analysis. In this step, the problem is
clearly understood. The construction of the problem and the relation among the
data items are identified. The condition to reach the solution among the multiple
could be identified.
Problem Understanding: Finding the maximum value among the given set of
numeric values.
Data Involved: Set of numeric values, Max Value: size of a single structure, the set
of numeric values have to be stored either sorted or unsorted.
clarification: Clarity of type of values. Whether the Set of Values are of Integer,
Real, etc.
Output: Highest value.
1.9.2 Program Design
The second step of problem solving is Program Design. In this step, we attempt to
identify the data involved properly and to arrive at a solution.
Algorithm:
Step 1: Start
Step 2: Declare Notation N, N Values[ ], MaxValue, I
Step 3: Read Value for N
Step 4: Repeat step 5 for N times
Step 5: Read Values and store in NValues[I] data structure
Step 6: I = 1
Step 7: MaxValue = NValues[0]
Step 8: If I < N then
If NValues[I] > MaxValue then
MaxValue = NValues[I]
Increment I by 1; Go to Step 8
Step 9: Print “Highest Value in Set:”, MaxValue
Step 10: Stop
1.9.3 Program Implementation
The programming language get up in this step. The logic defined in algorithm are
implemented as executable program using suitable programming instructions.
The above algorithm to be written in Python Language.
# Largest of N Numbers
N = int(input("Enter Size of List: "))
NValues = []
for i in range(N):
[Link](int(input("Enter Value: ")))
i=0
MaxValue = NValues[i]
while i < N:
if NValues[i] > MaxValue:
MaxValue = NValues[i]
i=i+1
print("Highest Value in List :", MaxValue)
1.9.4 Program Testing
The program developed based on problem solving steps may also have some
errors. Testing is the important part of solution development stage identify error in
program. Some sort of testing work can be done along with development. Testing
at end of development is done to test the entire functionality. The testing is done to
confirm whether the program produces correct solution defined in Problem
Analysis step. The error identified by the testing are rectified using Debugging.
Different possible inputs are given to test the program
Limitations of Computational Problem Solving
Every problem solution has to be computational with valid
building blocks. The computational problem solving procedure and
strategies can be carried out for each part of the building block of the
problem. Though the strategy gives logical approach in listing the solution,"
Page 1.14 – Python Programming Fundamentals
> of critical problem statement it has some limitations when the problem statement
needs to work on large volume of data, different structure of data, variety of data
The nature of latest problems which revolves on the data may not be applied with
computational method because the procedure is computation, algorithm is oriented
which helps to find the optimal step by step activities. The algorithm works
towards the well-defined output. There are some problems for which the output
may not be known in advance, so it is hard to define the step of activities.
Consider a system to be built for the automation activity based on the Artificial
Intelligence. The system has to work and act according to the dynamic varying and
unpredictable input. The defined step of computational solving is not sufficient for
these kinds of Artificial Intelligence problems.
In terms of the computing hardware the computational problem defines the
procedure with a defined set of bounded hardware configuration. That is not
suitable for non-computational problems which require infinite computing
resources.
Computation timing is another challenge in all the problem solving methods. There
may be different algorithms to find the same solution but each will take different
time to complete the task and give a final output. The one which takes less amount
of time complexity (less memory access time, less number of iterations in solution
steps) will be considered as an optimal solution. But non-computation problems
have to be given more computing time.
.10 INTRODUCTION TO PYTHON
Guido van Rossum is creator of Python first released in early 1990.
It is a powerful but simple programming language. Python is High Level
programming language supports for both procedural oriented and Object Oriented
Programming structure of program design. This language contains lots of inbuilt
functions, modules and class using which many complicated problems in Data
Science problems, Text Mining, Natural Language Processing, Internet of Things,
Artificial Intelligence and etc., could be found best solution. It has been used by
many of leading companies in Information Technology Industries.
Fundamentals
1.10.1 Features of Python
Python language have following features which facilitates the programmer to
create feasible solution for problem.
Easy to Code: Due to simple syntax facility the language is easy to learn.
Free and Open Source: Python Software is freely available. The in-built
functional codes are open sources so that they are accessible and sharable.
Object Oriented: Support Object Oriented Programming concepts like
Inheritance, Encapsulation and Polymorphism
Graphical User Interface (GUI) Programming support: Support to create
graphical applications
High Level Programming Language: It is high level programming language. It is
in human understandable form. The program can be written independent of internal
hardware architecture of computer.
Extensible Feature: The implemented features can be easily modified by
including new features without altering the existing one.
Portable Language: The program written on particular Operating System can be
moved to another System with different Operating System. And the same program
can be executed without any alteration. Only thing is the system must be installed
with Python interpreter.
Integrated Language: Python can be integrated with other programming language
like C, C++
Interpreter Language: Python programs are interpreted. So it gets executed in
line by line order. The Python Interpreter written in C language.
Large Standard Libraries: The language provides large set of inbuild modules
(funtions) and classes.
Dynamically typed language
the data type of variables( identifiers) are known only at run time .so there is no
need of declaring identifier before using it.
1.10.2 Installation of Python
Installing Python is easy process. Python software is available freely for all kind of
Operating Systems. Download latest version of Python Software with compatible
bit pattern (32 bit., 64 bit, etc.,) from [Link] web site. Just run the
downloaded exe file. The programs discussed in all the chapters are created and
run in Python 3.8.2 version run on Windows 10 Operating System.
1.10.3 Python Shell
Interactive mode of Python interpreter is Python Shell. Shell allows typing simple
commands and displaying the result. The Python Installed in System has Integrated
Development Environment (IDLE) to get Python Shell. The IDLE include options
to Edit the program, translate program into machine language and Debugging code.
Python translate the program into machine langue using interpreter. Open Shell in
Windows System: Type IDLE in Search → open
1.10.5 Program File
The program written in file can be stored permanently and used for any number of
times. Each of program files are referred as modules.
Open new file
Open Python Shell (Shell Command) → File → New.
Figure 1.15: Open New File
Type the program in file. The simple program to do the arithmetic calculation is
given.
# Simple Arithmetic
a= int(input("Enter Number a: "))
b= int(input("Enter Number b: "))
print("Addition :", a + b)
print("Subtraction :", a - b)
print("Multiplication :", a * b)
print("Division :", a / b)
First line of program preceded with # is comment statement
The next two lines are to get input of two numbers. The print() command used to
display the result of each arithmetic operation. The program have to be saved
before execution.
The type of files are differentiable by file extension. The extension of Python
file is .py
File → Save → Enter File Name → Give extension .py. To save the program
enter [Link] in File name field of Save dialog box.
In Python Shell type keyword import followed by file name
>>> import FileName
For above example program
>>> import BasicOp
>>> import BasicOp
Enter Number : 23
Enter Number : 25
Addition : 48
Subtraction : -2
Multiplication : 575
Division : 0.92
1.10.6 Program Environment
The program window contains menu options that provide the facility to change the
programming environment in comfortable manner. The program window open
from Python Shell include some default setting to differentiate keyword, user
defined identifier, font style.
File Menu: Contain options of new file creation, Opening existing file, Save, Save
As, Print and Close
Edit Menu: Include options of basic edit like cut, copy, paste, search, Go To,
search and replace. The special options are Show Completion and Expand word.
The Show Completions lists all the built in function and Classes. In order to take
particular function type first letter of function and select Show Completions, it
show the function or Class start in that.
The next special option in Edit menu is Expand word. This is to expand the
keyword just by typing first few characters. Type one or two letter and click
Expand Word. The remaining letter filled automatically. For example type letter ‘p’
and select Edit → Expand Word. It fill it as ‘print’.
Format Menu: The menu includes options to give indent, comment to lines and
remove it. The option 'New Indent Width' used to set the indent space. Default
indent space is 4.
Run Menu: Contain options to Run the program, move to Python Shell.
Options Menu: Contain option to show the code block, line numbers and
Configure IDLE. Using the option of line number provides easy reference to
particular programming statement. In order to get line number Options
The Option Configure IDLE shows the setting to change the font, color setting of
edit environment. The edit environment differentiate keyword, built in function,
class, comment statement, multi line comment statement and user identifier in
different color. The colors are modifiable using this setting. The navigation
shortcut keys can be modified. For example: Shortcut to go to first line of program
is (Ctrl + Home) that can be change. Similarly the shortcut keys for required
navigation are allowed to change
Windows Menu: It list the options to navigate between files currently in open
state and Python Shell option to move to Shell.
Help Menu: Contain options to know about IDLE version, Python Docs, Turtle
Demo, About IDLE. IDLE Version shows the version and copyright of IDLE.
Python Docs contain complete information about all version of Python software. It
include new feather of each Python version, installation procedure to be followed
for different Operating System and Tutorial with example to learn Python.
Turtle is a Class in Python to do some graphic display. Turtle Demo includes the
example codes of Turtle. More detail about Turtle is discussed in upcoming
chapters.
The last option in Help menu is About IDLE which shows options and facilities of
menus discussed so far.
1.10.7 Program Structure
The program should follow some standard rule in statement location and structure.
Single or Multiple Statements
Python program include different types of statements. As Python is an interpreter it
is allowed to write semantically correct Syntax Error Free statement in one line.
The interpreter read one line by identifying new line at end of statement. In below
code two print() statements are given. That two should be in separate line.
print("Hello")
print("Good Day")
Statements must be delimited by semi colon (;) to type more than one statements in
single line.
print("Hello"); print("Good Day")
Indentation
Strict Indent space level must be followed. The statement in same level must be
typed in same indent. The program statement starts from left end. One level of
indentation must be given if the statement falls in different group. In below
example the statement under ‘if’ is given one indent more than indent of ‘if’. The
matching pair of ‘if’ and ‘else’ must be given in the same indent space.
1 a=10
2 b=20
3 if a>b:
4 print("A is Greater")
5 else:
6 print("B is Greater")
The print() in line 4 given one indent more than ‘if’ because is under the ‘if’ block.
The line 6 given one indent more than ‘else’ because is under ‘else’ block. The key
word ‘if’ and matching ‘else’ are given in same indent level. More about
indentation is discussed in Chapter 3.
Explicit Line Split
The statement taking more than one line are indicated by back slash (\). It is an
indication to the interpreter that statement is continuing.
The print() function given in three lines of code. So each line explicitly ended by
back slash (\)
print(\
"Good\
Day")
SUMMARY
The internal structure and working procedure of system supports to make use of
the system efficiently. The analogy system transformed into digital form which
evolved later with more hardware interaction. The operating system act as middle
man is an interface between the user and system hardware. The programming
languages are used to give instruction to the system. The large set of problems
have to follow the solving procedure to get the accurate results. The Python is
programming language used to give instruction to system through with many
complicated problems can be solved.
QUESTIONS AND ANSWERS
PART - A (2 MARKS)
1. Define an Algorithm.
Algorithm is finite number of unambiguous steps which systematically followed to
find the solution of given problem in stipulated time period. It is a generalized
procedure used to solve the problem.
2. Define Hardware
The physical components of computer are called hardware. Example: Monitor,
Keyboard, Hard disk.
3. Define Software.
Set of programming instruction are called Computer Software. The software
includes the data and document to be processed.
4. What is system software?
The computing instruction used to operate the computer is called System Software.
This software used to control and synchronize the communication between
components of computer.
Example: Driver Software, Operating System
5. What is application software?
The computing instructions used to solve user problem are called Application
Software. The application software are installed only when it is required.
Example: Calculator, Word Processor, Adobe Reader, Photo Shop
6. What is CPU?
Central Processing Unit (CPU) is the brain of computer contain digital logic circuit
able to interpret and execute instructions. The CPU includes Arithmetic Logical
Unit (ALU), Control Unit and Memory Registers.
7. What is programming language?
Programming language is set of notations, keywords to form an instruction which
instruct the computer to perform specific task. The program written using
programming language are referred as Computer Code.
8. What are the differences between RAM and ROM?
RAM ROM
Random Access Memory Read Only Memory
The content of memory can be read and write at any number of time The content
of memory are read only
It is a volatile memory, the content in this memory get vanished when power is
turn off It is non-volatile memory; the content of memory is permanent even
when the power is turn off
The programs currently in execution are stored in this memory The programs that
are needed permanently are stored in this.
9. What is Binary Number?
The number system with two digits 0 and 1 is a binary number system. The digit is
called bit (Binary Digit)
10. What is operating system?
Operating System is a System Software bridges user and Computer Hardware. It
integrates all the components of system, System Software and Application
Software running in system. It acts a middle-man between user program and all the
computer component.
Example: Window, UNIX, LINUX, Mac, iOS, Android.
11. What are the roles of operating system?
Role of Operating System are:
Process Management
Memory Management
File Management
Input and Output Management
Peripheral Management
12. What is programming syntax?
The communication / programming language follow some rules to form a meaning
full sentence. The programming language rules applied to form an instruction is
called syntax.
13. What is translator?
The translator is the software associated with programming languages used to
convert high level into machine language. The Compiler and Interpreter are two
translators.
14. What is Compiler?
The Compiler is a translator software which convert the program into machine
language. It convert entire program before starting the execution.
15. What is an Interpreter?
The Interpreter is a translator software which convert the program into machine
language in instruction (one line) by instruction order. Execution of translated line
gets completed immediately before translating the next line.
16. What is Python Shell?
Interactive mode of Python interpreter is Python Shell. Shell allow to type simple
commands and display the result.
17. What is explicit line split?
The statement taking more than one line are indicated by back slash (). It is an
indication to the interpreter that statement is continuing.
Example
print(\
"Good\
Day")
DESCRIPTIVE QUESTIONS
PART - B & C (5 & 10 MARKS)
1. Write an algorithm for finding the largest of three numbers.
2. Write an algorithm to find the sum of n numbers
3. Write an algorithm to find the factorial of n numbers
4. What is peripherals? List out any five peripherals with short description
5. Write short notes about the evolution of programming language?
6. Explain the steps involved in computational problem solving?
7. What are the features of Python programming language?
QUESTIONS AND ANSWERS
PART - A (2 MARKS)
1. What is arithmetic overflow?
The result of arithmetic calculation exceeds the range of number is called as
Arithmetic Overflow.
>>> 1.23e200 * 2.3e300
Inf
2. What is arithmetic underflow?
The result of arithmetic which is very small to represent in the number system is
called Arithmetic Underflow.
>>> 1.23e-500 / 2.3e100
0.0
3. What is Unicode?
The universal encode scheme is a collection of different encoding method range
from 8 to 32 bits. There are lakhs of Unicode characters to encode many language
around the world. UTF-8 is the compactable ASCII (American Standard Code for
Information Interchange) encode used in common.
4. What is control character or escape sequence?
The characters that does not display on screen but control the display are control
characters.
\n New Line, Display the following content in next line.
\\ Backslash, Display one back slash character in output
5. What is variable?
The identifier for which the value can be changed through-out the program is
called variable. The name of variable are case sensitive in Python.
6. List the rules to be followed in naming the variable / identifiers.
Variable name can be in upper case or lower case of alphabets (a to z or A to Z)
8. Explain the need of indentation in Python code with an example.
➢ Variable name can have only one special character under score (_) in any
location. No other special characters are allowed.
➢ Variable can have numbers except as first character.
➢ No Key words can be used as variable name.
7. What is keyword?
Keywords are reserved words of programming language or keywords are
predefined identifier. There are used in programming syntax.
Some of the key words are:
False for is def global class
True break in del nonlocal import
if continue as try yield lambda
else or pass except from raise
elif and raise finally None return
while not return with assert
8. What is coercion / Type conversion?
Converting different data type into common data type implicitly (automatically) is
called coercion. This is performed only when there is safe conversion.
9. What is comment line?
The comment statements are non executable statements. There are types of
comment statements. That are single line comment and multi line comments.
# Single Line Comment
'''Line 1
Line 2
Multi Line comment...'''
DESCRIPTIVE ANSWERS
PART - B & C (5 & 10 MARKS)
1. Explain about literals in Python.
2. Explain about format() function with an example.
3. What is an operator? Explain any five operators in Python.
4. Explain about member operator in Python.
5. Explain the importance of operator precedence rule with an example.
6. Write short note on Arithmetic Expression and Boolean Expression.
7. Write note on data types.
8. What is the use of function type()? Explain with an example.
9. Explain the components/parameter/syntax of print() function.
10. Write Python program to do the arithmetic operations for given value.
11. Write Python program to find the whether given string is substring of other
using Member operator.