Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Write the syntax of while loop?

Answer»

The syntax of while loop in Python has the following syntax:

Syntax:

while: statements block 1

[else: statements block 2]

2.

Write a program to display multiplication table for a given number?

Answer»

Multiplication table

num = int (input(“Enter the number : “))

print (“multiplication Table of “ , num)

for i in range(1, 11):

print (num, “x” , i, ” = ” , num*i)

Output:

Enter the number: 6

Multiplication Table of 6

6 × 1 = 6

6 × 2 = 12

6 × 3 = 18

6 × 4 = 24

6 × 5 = 30

6 × 6 = 36

6 × 7 = 42

6 × 8 = 48

6 × 9 = 54

6 × 10 = 60

3.

Explain the two parameters of print ( ) function?

Answer»

print can have end, sep as parameters, end parameter can be used when we need to give any escape sequences like ‘\t’ for tab, ‘\n’ for new line and so on. sep as parameter can be used to specify any special characters like, (comma); (semicolon) as separator between values

4.

Escape sequences can be given using ………. parameter in print ( ) function.(a) Ret(b) Let(c) End(d) Sep

Answer»

Escape sequences can be given using End parameter in print ( ) function.

5.

How many parameters are there in print function?(a) 2(b) 3(c) 4(d) 5

Answer»

There are 2 parameters in print function

6.

What types of Expressions can be given in the while loop?(a) Arithmetic(b) Logical(c) Relational(d) Boolean

Answer»

Answer is (d) Boolean

7.

……….. statement provides control to check the true block as well as the false block.

Answer»

If ………. else

8.

Define loops?

Answer»

Iteration or loop are used in situation when the user need to execute a block of code several of times or till the condition is satisfied. A loop statement allows to execute a statement or group of statements multiple times.

9.

List the differences between break and continue statements?

Answer»

Break statement:

Break statement has even skipped the ‘else’ part of the loop and has transferred the control to the next line following the loop block.

Continue statement:

Continue statement unlike the break statement is used to skip the remaining part of a loop and start with next iteration.

10.

Write the program to calculate the sum of numbers from 1 to 100.Example: # program to calculate the sum of numbers 1 to 100

Answer»

n = 100

sum = 0

for counter in range (1, n + 1):

sum = sum + counter

print (“Sum of 1 until %d: %d” % (n,sum))

Output:

Sum of 1 until 100: 5050

11.

Name the different types of alternative statements in Python?

Answer»

Python provides the following types of alternative or branching statements:

Simple if statement if……else statement if….elif statement

12.

How many keywords are there to achieve Jump statements in python?(a) 1(b) 2(c) 3(d) 4

Answer»

There are 3 keywords to achieve Jump statements in python

13.

………. is used to come out of loop.(a) Break(b) For(c) Continue(d) Pass

Answer»

Break is used to come out of loop.

14.

Define nested loops?

Answer»

A loop placed within another loop is called as nested loop structure. One can place a while within another while; for within another for; for within while and while within for to construct such nested loops.

15.

…………… is the simplest of all decision making statements.

Answer»

Simple If is the simplest of all decision making statements.

16.

Which parameter is used to specify any special characters?(a) Ret(b) Leta(c) End(d) Sep

Answer»

Sep is used to specify any special characters

17.

range ( ) generates a list of values starting from start till ……

Answer»

range ( ) generates a list of values starting from start till Stop – 1

18.

The end value of range (30, 3, -3) is ……..(a) 30(b) -3(c) 3(d) 6

Answer»

The end value of range (30, 3, -3) is 6

19.

What is the output of the following snippet?i = 1while True:if i % 3 = 0:breakprint(i, end = “)i + = 1(a) 12(b) 123(c) 1234(d) 124

Answer»

Answer is (a) 12

20.

Branching statements are otherwise called as …… (a) Alternative(b) Iterative (c) Loop(d) Sequential

Answer»

(a) Alternative

21.

If the condition is checked in the beginning of the loop, then it is called as ……… loop.(a) Exit(b) Exit check(c) Entry check(d) Multiple

Answer»

(c) Entry check

22.

Which is the most comfortable loop?(a) do..while(b) While(c) For(d) if….elif

Answer»

For is the most comfortable loop

23.

range ( ) cannot take the values from ……(a) String(b) Print(c) List(d) Dictionary

Answer»

range ( ) cannot take the values from Print

24.

range(20) has the range value from …….. to ......

Answer»

range(20) has the range value from 0 to 19

25.

…….. statement forces the next iteration to takes place.(a) Break(b) For(c) Continue(d) Pass

Answer»

Continue tatement forces the next iteration to takes place.

26.

………. is the null statement.(a) Break (b) For (c) Continue (d) Pass

Answer»

Pass is the null statement.

27.

A loop placed within another loop is called as ………

Answer»

A loop placed within another loop is called as Nested loop

28.

What is the output of the following snippet?T = 1 while T: print(True) break(a) False(b) True(c) 0(d) No output

Answer»

(d) No output

29.

Which punctuation should be used in the blank?if _statements – block 1else:statements – block 2else:(a) ;(b) :(c) :: (d) !

Answer»

Answer is (b) :

30.

The condition in the if statement should be in the form of …….(a) Arithmetic or Relational expression(b) Arithmetic or Logical expression(c) Relational or Logical expression(d) Arithmetic

Answer»

(c) Relational or Logical expression

31.

A ……… is composed of a sequence of statements which are executed one after the another.

Answer»

Sequential Statement

32.

Write note on break statement?

Answer»

The break statement terminates the loop containing it. Control of the program flows to the statement immediately after the body of the loop.

33.

If a loop is left by ……… then the else part is not executed.

Answer»

If a loop is left by Break then the else part is not executed.

34.

Which is the optional part in range ( ) function?(a) Start(b) Stop(c) Step(d) Incr

Answer»

Step is the optional part in range ( ) function

35.

Which amongst this is not a jump statement?(a) For(b) Goto(c) Continue(d) Break

Answer»

For is not a jump statement

36.

………….. statements are used to unconditionally transfer the control from one part of the program to another.(a) While(b) Jump(c) For(d) If

Answer»

jump statements are used to unconditionally transfer the control from one part of the program to another.

37.

Python …… will throw error for all indentation errors.

Answer»

Interpreter.

38.

Write note on sequential statements?

Answer»

A sequential statement is composed of a sequence of statements which are executed one after another. A code to print your name, address and phone number is an example of sequential statement.

39.

Identify which is not a control structure?(a) Sequential(b) Alternative(c) Iterative(d) Break

Answer»

Break is not a control structure

40.

Which statement is generally used as a placeholder? (a) Continue (b) Break(c) Pass(d) Goto

Answer»

Pass is generally used as a placeholder

41.

List the control structures in Python?

Answer»

There are three important control structures

1. Sequential

2. Alternative or Branching

3. Iterative or Looping

42.

Write note on Jump statements in python?

Answer»

The jump statement in Python, is used to unconditionally transfer the control from one part of the program to another. There are three keywords to achieve jump statements in Python : break, continue, pass.

43.

The …….. part of while is optional.

Answer»

The Else part of while is optional.

44.

Give the syntax of range O in for loop?

Answer»

The syntax of range ( ) is as follows:

range (start, stop, [step] ) Where,

start – refers to the initial value

stop – refers to the final value

step – refers to increment value, this is optional part.

45.

Write is the syntax of if else statement?

Answer»

Syntax:

if:

statements – block 

else:

statements – block 2

46.

Pick the odd one out.break, for, continue, pass.

Answer»

Answer is For

47.

Define control structure?

Answer»

A program statement that causes a jump of control from one part of the program to another is called control structure or control statement. As you have already learnt in C++, these control statements are compound statements used to alter the control flow of the process or program depending on the state of the process.

48.

Write short note on pass statements?

Answer»

pass statement in Python programming is a null statement, pass statement when executed by the interpreter it is completely ignored. Nothing happens when pass is executed, it results in no operation. pass statement can be used in ‘if’ clause as well as within loop construct, when you do not want any statements or commands within that block to be executed

49.

What plays a vital role in Python programming?(a) Statements(b) Control(c) Structure(d) Indentation

Answer»

(d) Indentation

50.

A program statement that causes a jump of control from one part of the program to another is called ……

Answer»

Control Structure.