0% found this document useful (0 votes)
4 views

Important Question For Python

important question

Uploaded by

Mrs. Lingeshwari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Important Question For Python

important question

Uploaded by

Mrs. Lingeshwari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

Q.1.What is algorithm ? AU : Jan.

-18

Ans. : Algorithm is an ordered sequence of finite, well defined,


unambiguous instructions for completing a task. It

is an English-like representation of the logic which is used to solve


the problem. It is a step-by-step

procedure for solving a task or a problem. The steps must be ordered,


unambiguous and finite in number.

Q. 2 Enlist the basic building blocks of algorithms.

Ans. : The basic building blocks of algorithms are - Assignment


statements, control statements and functions.

Q. 3 What is pseudo code ?

Ans. : Pseudocode is an artificial and informal language that helps


programmers develop algorithms. Pseudocode is a "text-based" detail
(algorithmic) design tool.

Q. 4 Define the flow chart.

Ans. : Flow chart is a graphical representation of the algorithm. Using


specific notations the algorithm is represented using the flow chart.

Q. 5 What is programming language ? Give examples.

Ans. : Programming languages are formal languages that have been


designed to implement algorithm.

Example - C, C++, Java, Python are some programming languages that


are used commonly.

Q. 6 Enlist different steps used in algorithmic problem solving.

Ans. : Various steps used in algorithmic problem solving are,

1. Identify the problem

2. Understand the problem

3. Identify the alternative ways to solve problem


4. Select the best way to solve the problem from the list of alternative
solution.

5. List the instructions using selected solution

6. Evaluate the solution.

Q. 7 What is recursion ?

Ans. : Recursion is a method of solving problems that involves breaking a


problem down into smaller and smaller subproblems until you get to a
small enough problem that it can be solved trivially.

Q.8. Write an algorithm to find minimum of three numbers.

ALGORITHM : Find Minimum of three numbers

Step 1: Start

Step 2: Read the three numbers A, B, C

Step 3: Compare A,B and A,C. If A is minimum, perform step 4 else


perform Step 4:Compare B and C. If B is minimum, output “B is minimum”
else output “C is minimum”.

Step 5: Stop

Q.9. List the building blocks of algorithm.

The building blocks of an algorithm are

 Statements

 Sequence

 Selection or Conditional

 Repetition or Control flow

 Functions

An action is one or more instructions that the computer performs in


sequential order (from first to last). A

decision is making a choice among several actions. A loop is one or more


instructions that the computer

performs repeatedly.
Q.10. Define statement. List its types.

The instructions in Python, or indeed in any high-level language, are


designed as components for algorithmic

problem solving, rather than as one-to-one translations of the underlying


machine language instruction set

of the computer. Three types of high-level programming language


statements. Input/output statements make

up one type of statement. An input statement collects a specific value


from the user for a variable within the

program. An output statement writes a message or the value of a program


variable to the user’s screen.

Q.11. Write the pseudocode to calculate the sum and product of


two numbers and display it.

INITIALIZE variables sum, product, number1, number2 of type real

PRINT “Input two numbers”

READ number1, number2

COMPUTE sum = number1 + number2

PRINT “The sum is", sum

COMPUTE product = number1 * number2

PRINT “The Product is", product

END program .

Q.12. How does flow of control work?

Control flow (or flow of control) is the order in which individual


statements, instructions or function calls

of an imperative program are executed or evaluated. A control flow


statement is a statement in which

execution results in a choice being made as to which of two or more paths


to follow.

Q.13. Write the algorithm to calculate the average of three


numbers and display it.
16 Marks

Step 1: Start
Step 2: Read values of
X,Y,Z
Step 3: S = X+Y+Z
Step 4: A = S/3
Step 5: Write value of A
Step 6: Stop
8. Give the rules for
writing Pseudocode.
 Write one statement
per line.
 Capitalize initial
keywords.
 Indent to show
hierarchy.
 End multiline
structure.
 Keep statements
language independent.
9. What is a function?
Functions are named
sequence of statements
that accomplish a
specific task. Functions
usually "take in"
data, process it, and
"return" a result. Once a
function is written, it can
be used over and over
and over again.
Functions can be
"called" from the inside
of other functions.
10. Give the difference
between flowchart and
pseudocode.
Flowchart
Pseudocode
 A flowchart is a
diagram showing an
overview of the
problem.
 It is a pictorial
representation of how
the program will work,
and it follows
a standard format.
 It uses different kinds
of shapes to
signify different
processes involved in
the problem
 Pseudocode is a
means of expressing the
stepwise instructions for
solving a
problem without
worrying about the
syntax of a particular
programming
language.
 Unlike a flowchart, it
uses a written
format which requires
no absolute rules
for writing.
 It can be written in
ordinary English, and
we can use some
keywords in it too.
11. Define a flowchart.
 A flowchart is a
diagrammatic
representation of the
logic for solving a task.
 A flowchart is drawn
using boxes of different
shapes with lines
connecting them to
show the flow of
control.
 The purpose of
drawing a flowchart is to
make the logic of the
program clearer in a
visual form.
12. Give an example of
iteration.
a=0
for i in range(4): # i
takes the value 0,1,2,3
a=a+i
print(a) #number 6
is printed
(0+0;0+1;1+2;3+3)
13. Write down the rules
for preparing a
flowchart.
While drawing a
flowchart, some rules
need to be followed:
 A flowchart should
have a start and end.
 The direction of flow
in a flowchart must be
from top to bottom and
left to right.
 The relevant symbols
must be used while
drawing a flowchart.
14. List the categories of
Programming languages
Step 1: Start
Step 2: Read values of
X,Y,Z
Step 3: S = X+Y+Z
Step 4: A = S/3
Step 5: Write value of A
Step 6: Stop
8. Give the rules for
writing Pseudocode.
 Write one statement
per line.
 Capitalize initial
keywords.
 Indent to show
hierarchy.
 End multiline
structure.
 Keep statements
language independent.
9. What is a function?
Functions are named
sequence of statements
that accomplish a
specific task. Functions
usually "take in"
data, process it, and
"return" a result. Once a
function is written, it can
be used over and over
and over again.
Functions can be
"called" from the inside
of other functions.
10. Give the difference
between flowchart and
pseudocode.
Flowchart
Pseudocode
 A flowchart is a
diagram showing an
overview of the
problem.
 It is a pictorial
representation of how
the program will work,
and it follows
a standard format.
 It uses different kinds
of shapes to
signify different
processes involved in
the problem
 Pseudocode is a
means of expressing the
stepwise instructions for
solving a
problem without
worrying about the
syntax of a particular
programming
language.
 Unlike a flowchart, it
uses a written
format which requires
no absolute rules
for writing.
 It can be written in
ordinary English, and
we can use some
keywords in it too.
11. Define a flowchart.
 A flowchart is a
diagrammatic
representation of the
logic for solving a task.
 A flowchart is drawn
using boxes of different
shapes with lines
connecting them to
show the flow of
control.
 The purpose of
drawing a flowchart is to
make the logic of the
program clearer in a
visual form.
12. Give an example of
iteration.
a=0
for i in range(4): # i
takes the value 0,1,2,3
a=a+i
print(a) #number 6
is printed
(0+0;0+1;1+2;3+3)
13. Write down the rules
for preparing a
flowchart.
While drawing a
flowchart, some rules
need to be followed:
 A flowchart should
have a start and end.
 The direction of flow
in a flowchart must be
from top to bottom and
left to right.
 The relevant symbols
must be used while
drawing a flowchart.
14. List the categories of
Programming languages
Step 1: Start
Step 2: Read values of
X,Y,Z
Step 3: S = X+Y+Z
Step 4: A = S/3
Step 5: Write value of A
Step 6: Stop
8. Give the rules for
writing Pseudocode.
 Write one statement
per line.
 Capitalize initial
keywords.
 Indent to show
hierarchy.
 End multiline
structure.
 Keep statements
language independent.
9. What is a function?
Functions are named
sequence of statements
that accomplish a
specific task. Functions
usually "take in"
data, process it, and
"return" a result. Once a
function is written, it can
be used over and over
and over again.
Functions can be
"called" from the inside
of other functions.
10. Give the difference
between flowchart and
pseudocode.
Flowchart
Pseudocode
 A flowchart is a
diagram showing an
overview of the
problem.
 It is a pictorial
representation of how
the program will work,
and it follows
a standard format.
 It uses different kinds
of shapes to
signify different
processes involved in
the problem
 Pseudocode is a
means of expressing the
stepwise instructions for
solving a
problem without
worrying about the
syntax of a particular
programming
language.
 Unlike a flowchart, it
uses a written
format which requires
no absolute rules
for writing.
 It can be written in
ordinary English, and
we can use some
keywords in it too.
11. Define a flowchart.
 A flowchart is a
diagrammatic
representation of the
logic for solving a task.
 A flowchart is drawn
using boxes of different
shapes with lines
connecting them to
show the flow of
control.
 The purpose of
drawing a flowchart is to
make the logic of the
program clearer in a
visual form.
12. Give an example of
iteration.
a=0
for i in range(4): # i
takes the value 0,1,2,3
a=a+i
print(a) #number 6
is printed
(0+0;0+1;1+2;3+3)
13. Write down the rules
for preparing a
flowchart.
While drawing a
flowchart, some rules
need to be followed:
 A flowchart should
have a start and end.
 The direction of flow
in a flowchart must be
from top to bottom and
left to right.
 The relevant symbols
must be used while
drawing a flowchart.
14. List the categories of
Programming languages
8.Describe the algorithm of towers of Hanoi problem. Suggest a solution
to the tower of Hanoi problem with relevant diagram?

9. Draw a flow chart to accept three distinct numbers find the greatest
and print the results?

10.(i) Describe the pseudocode for Fibonacci sequence. (ii) Draw a


flowchart for factorial of given number?

11. Describe the program to insert an element in a sorted list?

12. Draw the flowchart to find a sum of series 1+2+3+4+ ...............


+100.
13.Summarize the difference between algorithm, flowchart, and
seudocode?

14.Explain algorithm problem solving technique in detail?

GE3151 – Problem Solving


and Python Programming
Common to all Branches
2021-2022
St. Joseph’s Institute of
Technology
7
Programming
Languages are divided
into the following
categories:
 Interpreted
 Functional
 Compiled
 Procedural
 Scripting
 Markup
 Logic-Based
 Concurrent
 Object-Oriented
Programming
Languages.
15. Mention the
characteristics of
algorithm.
 Algorithm should be
precise and
unambiguous.
 Instruction in an
algorithm should not be
repeated infinitely.
 Ensure that the
algorithm will ultimately
terminate.
 Algorithm should be
written in sequence.
 Algorithm should be
written in normal
English.
 Desired result should
be obtained only after
the algorithm
terminates
16. List out the simple
strategies to develop an
algorithm.
Algorithm development
process consists of five
major steps.
Step 1: Obtain a
description of the
problem.
Step 2: Analyze the
problem.
Step 3: Develop a high-
level algorithm.
Step 4: Refine the
algorithm by adding
more detail.
Step 5: Review the
algorithm
GE3151 – Problem Solving
and Python Programming
Common to all Branches
2021-2022
St. Joseph’s Institute of
Technology
7
Programming
Languages are divided
into the following
categories:
 Interpreted
 Functional
 Compiled
 Procedural
 Scripting
 Markup
 Logic-Based
 Concurrent
 Object-Oriented
Programming
Languages.
15. Mention the
characteristics of
algorithm.
 Algorithm should be
precise and
unambiguous.
 Instruction in an
algorithm should not be
repeated infinitely.
 Ensure that the
algorithm will ultimately
terminate.
 Algorithm should be
written in sequence.
 Algorithm should be
written in normal
English.
 Desired result should
be obtained only after
the algorithm
terminates
16. List out the simple
strategies to develop an
algorithm.
Algorithm development
process consists of five
major steps.
Step 1: Obtain a
description of the
problem.
Step 2: Analyze the
problem.
Step 3: Develop a high-
level algorithm.
Step 4: Refine the
algorithm by adding
more detail.
Step 5: Review the
algorithm
GE3151 – Problem Solving
and Python Programming
Common to all Branches
2021-2022
St. Joseph’s Institute of
Technology
7
Programming
Languages are divided
into the following
categories:
 Interpreted
 Functional
 Compiled
 Procedural
 Scripting
 Markup
 Logic-Based
 Concurrent
 Object-Oriented
Programming
Languages.
15. Mention the
characteristics of
algorithm.
 Algorithm should be
precise and
unambiguous.
 Instruction in an
algorithm should not be
repeated infinitely.
 Ensure that the
algorithm will ultimately
terminate.
 Algorithm should be
written in sequence.
 Algorithm should be
written in normal
English.
 Desired result should
be obtained only after
the algorithm
terminates
16. List out the simple
strategies to develop an
algorithm.
Algorithm development
process consists of five
major steps.
Step 1: Obtain a
description of the
problem.
Step 2: Analyze the
problem.
Step 3: Develop a high-
level algorithm.
Step 4: Refine the
algorithm by adding
more detail.
Step 5: Review the
algorithm

You might also like