Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

Python Question Bank

Uploaded by

stylishdeepak95
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Python Question Bank

Uploaded by

stylishdeepak95
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

DPG Polytechnic

Gurgaon, HR
Question Bank

Programme: Diploma (CSE)


Course Name: COMPUTER ENGINEERING
Course Code: 180853- Computer Programming using Python
Blooms COs
Questions Level

SECTION-A

Q1 The extension of a Python Script File 1


is 1
a)
. .py
b) .pyy
c) .pie
d) None these
How to add a single-line comment in
Q2 Python? 1 1
/*This is
a) comment*/ b) !! This is comment
c) // This is comment d) # This is comment

Q3 How to correctly create a function in python? 2

a) demoFunction() 1
b) def demoFunction()
c) function demoFunction()
d) void demoFunction()
Q4 Which statement is used to bring control to the 2
beginning of the loop? 1

a) for b) break
c) continue d) none of the above
Q5 Which of the following statement is not used for 3
exception handling ? 1

a) try b) except
c) finally d) if
Which of the following are greedy match
6 quantifiers?
a) ‘*’ 1
b) ‘+’ 4
c) ‘?’
d) all above

Q7 4
Which function is used to open a file in Python? 1

a) file () b) new()
c) open() d) none of these

Q8 Which statement import all the functionally of one 3


module to another? 1
a) import b) try
c) exception d) from import

Q9 Which of the following is not a python language 1


Features?
1
a) Interpreted b) general purpose
c) object oriented d) Machine dependent

Q10 Which one of the following is not a python’s 4


predefined data type?
a) List b) Dictionary 1
c) Tuple d) Class

Q11 4
Which code is used to open a file for binary writing? 1
a) “w”
b) “wb”
c) “r+”
d) “a”
Q12 Which of the following functions returns a list 1
containing all matches?
a) Find b) Findall
c) Search d) None of the above

_____ uses square brackets for comma


separated
Q13 values in Python? 1 2

a) List b) Dictionary

C Tuples d)
None of the
above

Name the thing which does not allow duplicate


Q14 Values 1 1

a) Set b) Lists
c) Tuples d) None of the above

Q15 Name the thing which represents a key-value pair 2


1
b)
a) Tuples Lists
c) Dictionary d) all of the above

Name the operator used in Python to raise numbers


Q16 to the power? 1 1
a) Bitwise Operators b) Exponentiation Operator
c) Identify Operators d) Membership Operators

How to access
a value in
Q17 Tuple? 1 1

a) mytuple (1)
b) mytuple [1]
c) mytuple {1}
d) None of the above
Q18 The following is an example of an invalid variable? 1 1

a)
xyz_
1 b) 1st
c)
foo d) _qwe
Q19 2
A variable in Python with value 42.6
1

a) int a = 42.6
b) a = 42.6
c) integer a = 42.6
d) None

Q20 2
How to access a value in List?

a) mylist() b) mylist[] 1
c) mylist {} d) none

SECTION-B

Write the statement import all the functionality of


Q21 one module to another module. 1

3
Q22 Is Python is an object-oriented language? (T/F) 1 1

Write the syntax to open a file in read


Q23 and write mode. 1 4

Except code block is always executed


before try code
block in python exception handling.
Q24 (True/False) 2 3

Write any two common exception handled in


Q25 Python. 1 3

Q26 OOPS stands for_________ 2 4

Python Language was developed


Q27 by............... 1 1

Q28 The return keyword is used in Python 1 2


for..............

The variables declared outside of a


Q29 function have scope.. 1 1

Q30 Give the purpose of input function. 1 2


Write the character which is used for searching
Q31 from the end. 1 4

The elements of a list can be accessed by using


Q32 which operator. 1 2

Name the module in Python which supports regular


Q33 expression? 1 4

Q34 Define class. 4

1
SECTION-C

Q35 Briefly explain History and Versions of Python? 2 1

Q36 Difference between break and continue statement. 2


4
Q37 Difference between list and tuple. 2
4
Explain the advantages of using a function in
Q38 Python programming 2 2

Q39 Define a class and how it is created in Python 1 4

Q40 2
Write a program in Python to check if a number is prime or not. 1
Q41 Explain the nesting of loops in python with example 2 2

Q42 Explain various file opening access modes 2 3

What are modules. Write a module to add two


Q43 numbers. 1 3

SECTION-D

Q44 2
Explain the use of various types of operators in python
2
What do you be Tuples in Python. Explain various type
Q45 of operation of tuples. 1 2

What is class and object? How they are


Q46 implemented in Python explain with examples? 1 4
Q47 4
Describe inheritance and explain the various types
of python inheritance with the help of suitable
examples. 1

Write short notes with example on


a) map()
b) filter()
c) lambda ()
Q48 d) closures () 1 2

Q49 Explain the use of various regular expression methods 4


a) re.search () b) re.match ()
c) re.findall () 2

Q50 Explain modules and its types. 2 2

You might also like