22IT1151- PYTHON PROGRAMMING AND PRACTICES – QUESTION BANK
UNIT I PART-A- Two marks
1. Define Algorithm
Algorithm : It is a sequence of instructions designed in such a way that if the
instructions are executed in the specified sequence, the desired results will be obtained.
The instructions in an algorithm should not be repeated infinitely. The algorithm should
be written in simple English language.
2. What is the difference between hardware and software?
Hardware refers to the physical and visible components of the system such as a
monitor, CPU, keyboard and mouse.
Software, on the other hand, refers to a set of instructions which enable the
hardware to perform a specific set of tasks.
3. What are the properties of algorithm?
• It is written in simple English.
• Each step of an algorithm is unique and should be self
• explanatory. An algorithm must have at least one input.
• An algorithm must have at least one
• output. An algorithm has finite number of steps.
4. What are the building block of algorithm?
The building block of algorithm are :
• Statement
• Sequence
• Selection
• Iteration
5. Define sequence ,iteration and selection control structures?
1.Sequence:
All the instructions are executed one after another is called sequence execution.
2. Selection
selection statement causes the program control to be transferred to a specific part of
the program based upon the condition.
3. Iteration:
certain set of statements are executed again and again based upon conditional test.
i.e. executed more than one time. This type of execution is called looping or iteration.
6. Define Flowchart
It is a pictorial representation of an algorithm. The flowchart uses different shape
symbols to denote the different appropriate instructions and these instructions can be
written within the boxes using clear statements.
7. Write the Characteristics of Pseudo code.
• Named variables represent data and identifiers
• Composed of a sequence of statements or steps.
• Operational (Imperative) statements include assignment, input, and output Control
structures provide iterative and conditional execution.
• Indentations used for grouping
,8. Write some rules for drawing a flowchart.
• The flowchart should be clear, neat and easy to follow.
• The flowchart must have a logical start and finish.
• Only one flow line should come out from a process symbol.
• Only one flow line should enter a decision symbol. However, two or three flow lines
may leave the decision symbol.
• Only one flow line is used with a terminal symbol.
• Within standard symbols, write briefly and precisely.
9. What are the advantages of using a flowchart
• Communication
• Effective
• Proper Documentation
• Efficient Coding
• Proper Debugging
• Efficient Program Maintenance
10. Disadvantages/Limitation of using flowchart
• Complex logic
• Alterations and Modifications
• Reproduction
• High Cost
•
11. What is Pseudo code?
• Pseudo‖ means imitation of false and
• code‖ refers to the instruction written in a programming language.
• Pseudo code is programming analysis tool that is used for planning program
logic.
• The keywords should be written in capital letters. Eg: READ, WRITE,
IF, ELSE, ENDIF, WHILE, REPEAT, UNTIL
12. What are the rules for writing pseudo
code?
• Write one statement per line.
• Capitalize initial keywords.
• Indent to show hierarchy.
• End multiline structure.
13. Write any two advantages of pseudo code.
It can be done easily in any word
processor.
• It can be written easily.
• It can be easily modified as compared to flowchart.
14. Differentiate Algorithm and Pseudo code
S.No Algorithm Pseudocode
1. It is a well-defined procedure that It is a simple way of writing programming code
allows a computer to solve a problem. in English.
2. Algorithms can be described in Pseudo code describes how you would
various ways, from pure mathematical implement an algorithm without getting into
formulas to complex graphs syntactical details.
,15. What is the difference between algorithm and flowchart
S.No Algorithm Flow Chart
1. Step by Step formation Box by box formation
Mostly run to complete or manage a Can be used in general terms to solve any
2. program implementation. problem related to an individual or a group.
More detailed but difficult to Less detailed but easy to understand by everyone.
3. Understand
16. What is recursion? give an example.
❖ A function that calls itself is known as recursion.
❖ Recursion is a process by which a function calls itself repeatedly until some
specified condition has been satisfied.
Example
factorial=n*factorial(n-1)
17. Mention any four High level languages
• C,
• C++
• Java
• Python
18. Differentiate Compiler and Interpreter
Interpreter Compiler
Translates one statement at a time into Scans entire program and translates it as
machine code whole into machine code
It takes less amount of time to analyze the It takes large amount of time to analyze the
source code source code
No intermediate object code is generated, Generates intermediate object code which
hence are memory efficient further requires linking
Interpreter language - Python, Ruby Compiler language: C,C++,Java
19. Compare Iteration and Recursion
Iteration Recursion
The process is repeated until the The function calls itself until the base
condition fails. condition is satisfied.
It consumes less memory. It consumes more memory
It is faster It is slower
The code is long . The code is short.
Tracing is easier if any problem Tracing is difficult if any problem occurs.
occurs
20. Write down the steps for algorithmic problem solving methodology.
1. Understanding the Problem
2. Ascertaining the Capabilities of the Computational Device
3. Design Algorithm
4. Analyzing Algorithm
5. Coding the algorithm as Program
, 22IT1151- PYTHON PROGRAMMING AND PRACTICES--- UNIT I NOTES
1. What is an Algorithm ? Explain the building blocks of an algorithm.
Algorithm is a step by step procedure in English language to solve the problem.
The building blocks of algorithm are
• Statements
• State
• Control flow
• Functions
Statements:
Statement is a single action in a computer. In a computer statements might include some of the following
actions
➢ input data-information given to the program
➢ process data-perform operation on a given input
➢ output data-processed result
State:
Transition from one process to another process under specified condition with in a time is called state.
Control flow:
The process of executing the individual statements in a given order is called control flow. The control
can be executed in three ways
1. sequence
2. selection
3. iteration
1.Sequence:
All the instructions are executed one after another is called sequence execution.
Example: Algorithm to Add two numbers:
Step 1: Start
Step 2: get a,b
Step 3: calculate c=a+b
Step 4: Display c
Step 5: Stop
2. Selection:
A selection statement causes the program control to be transferred to a specific part of the
program based upon the condition.
If the conditional test is true, one part of the program Action 1
will be executed, otherwise it will execute the other part of
the program Action 2.
UNIT I PART-A- Two marks
1. Define Algorithm
Algorithm : It is a sequence of instructions designed in such a way that if the
instructions are executed in the specified sequence, the desired results will be obtained.
The instructions in an algorithm should not be repeated infinitely. The algorithm should
be written in simple English language.
2. What is the difference between hardware and software?
Hardware refers to the physical and visible components of the system such as a
monitor, CPU, keyboard and mouse.
Software, on the other hand, refers to a set of instructions which enable the
hardware to perform a specific set of tasks.
3. What are the properties of algorithm?
• It is written in simple English.
• Each step of an algorithm is unique and should be self
• explanatory. An algorithm must have at least one input.
• An algorithm must have at least one
• output. An algorithm has finite number of steps.
4. What are the building block of algorithm?
The building block of algorithm are :
• Statement
• Sequence
• Selection
• Iteration
5. Define sequence ,iteration and selection control structures?
1.Sequence:
All the instructions are executed one after another is called sequence execution.
2. Selection
selection statement causes the program control to be transferred to a specific part of
the program based upon the condition.
3. Iteration:
certain set of statements are executed again and again based upon conditional test.
i.e. executed more than one time. This type of execution is called looping or iteration.
6. Define Flowchart
It is a pictorial representation of an algorithm. The flowchart uses different shape
symbols to denote the different appropriate instructions and these instructions can be
written within the boxes using clear statements.
7. Write the Characteristics of Pseudo code.
• Named variables represent data and identifiers
• Composed of a sequence of statements or steps.
• Operational (Imperative) statements include assignment, input, and output Control
structures provide iterative and conditional execution.
• Indentations used for grouping
,8. Write some rules for drawing a flowchart.
• The flowchart should be clear, neat and easy to follow.
• The flowchart must have a logical start and finish.
• Only one flow line should come out from a process symbol.
• Only one flow line should enter a decision symbol. However, two or three flow lines
may leave the decision symbol.
• Only one flow line is used with a terminal symbol.
• Within standard symbols, write briefly and precisely.
9. What are the advantages of using a flowchart
• Communication
• Effective
• Proper Documentation
• Efficient Coding
• Proper Debugging
• Efficient Program Maintenance
10. Disadvantages/Limitation of using flowchart
• Complex logic
• Alterations and Modifications
• Reproduction
• High Cost
•
11. What is Pseudo code?
• Pseudo‖ means imitation of false and
• code‖ refers to the instruction written in a programming language.
• Pseudo code is programming analysis tool that is used for planning program
logic.
• The keywords should be written in capital letters. Eg: READ, WRITE,
IF, ELSE, ENDIF, WHILE, REPEAT, UNTIL
12. What are the rules for writing pseudo
code?
• Write one statement per line.
• Capitalize initial keywords.
• Indent to show hierarchy.
• End multiline structure.
13. Write any two advantages of pseudo code.
It can be done easily in any word
processor.
• It can be written easily.
• It can be easily modified as compared to flowchart.
14. Differentiate Algorithm and Pseudo code
S.No Algorithm Pseudocode
1. It is a well-defined procedure that It is a simple way of writing programming code
allows a computer to solve a problem. in English.
2. Algorithms can be described in Pseudo code describes how you would
various ways, from pure mathematical implement an algorithm without getting into
formulas to complex graphs syntactical details.
,15. What is the difference between algorithm and flowchart
S.No Algorithm Flow Chart
1. Step by Step formation Box by box formation
Mostly run to complete or manage a Can be used in general terms to solve any
2. program implementation. problem related to an individual or a group.
More detailed but difficult to Less detailed but easy to understand by everyone.
3. Understand
16. What is recursion? give an example.
❖ A function that calls itself is known as recursion.
❖ Recursion is a process by which a function calls itself repeatedly until some
specified condition has been satisfied.
Example
factorial=n*factorial(n-1)
17. Mention any four High level languages
• C,
• C++
• Java
• Python
18. Differentiate Compiler and Interpreter
Interpreter Compiler
Translates one statement at a time into Scans entire program and translates it as
machine code whole into machine code
It takes less amount of time to analyze the It takes large amount of time to analyze the
source code source code
No intermediate object code is generated, Generates intermediate object code which
hence are memory efficient further requires linking
Interpreter language - Python, Ruby Compiler language: C,C++,Java
19. Compare Iteration and Recursion
Iteration Recursion
The process is repeated until the The function calls itself until the base
condition fails. condition is satisfied.
It consumes less memory. It consumes more memory
It is faster It is slower
The code is long . The code is short.
Tracing is easier if any problem Tracing is difficult if any problem occurs.
occurs
20. Write down the steps for algorithmic problem solving methodology.
1. Understanding the Problem
2. Ascertaining the Capabilities of the Computational Device
3. Design Algorithm
4. Analyzing Algorithm
5. Coding the algorithm as Program
, 22IT1151- PYTHON PROGRAMMING AND PRACTICES--- UNIT I NOTES
1. What is an Algorithm ? Explain the building blocks of an algorithm.
Algorithm is a step by step procedure in English language to solve the problem.
The building blocks of algorithm are
• Statements
• State
• Control flow
• Functions
Statements:
Statement is a single action in a computer. In a computer statements might include some of the following
actions
➢ input data-information given to the program
➢ process data-perform operation on a given input
➢ output data-processed result
State:
Transition from one process to another process under specified condition with in a time is called state.
Control flow:
The process of executing the individual statements in a given order is called control flow. The control
can be executed in three ways
1. sequence
2. selection
3. iteration
1.Sequence:
All the instructions are executed one after another is called sequence execution.
Example: Algorithm to Add two numbers:
Step 1: Start
Step 2: get a,b
Step 3: calculate c=a+b
Step 4: Display c
Step 5: Stop
2. Selection:
A selection statement causes the program control to be transferred to a specific part of the
program based upon the condition.
If the conditional test is true, one part of the program Action 1
will be executed, otherwise it will execute the other part of
the program Action 2.