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

python (1)

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

python (1)

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

Computer

Subject : Comp. Prog. Using Python

SECTION-A
Note:- Multiple choice questions.
Q.1 Which of the following is not a python language features.
a) Interpreted b) general purpose
c) object oriented d) Machine dependent
Q.2 How to add a single-line -comment in Python?
a) #this is single line comment
b) !!this is single line comment
c) // this is single line comment
d) \\ this is single line comment
Q.3 Which statement is used to bring control to the beginning of the loop?
a) for b) break
c) continue d) none of the above
Q.4 How to access a value in List?
a) mylist() b) mylist[]
c) mylist {} d) none
Q.5 Which keyword is used for creating a function in Python ?
a) function b) define
c) def d) fun
Q.6 Which statement import all the functionally of one module to another?
a) import b) try
c) exception d) from import
Q.7 Which of the following statement is not used for exception handling ?
a) try b) except
c) finally d) if
Q.8 Which function is used to open a file in Python?
a) file () b) new()
c) open() d) none of these
Q.9 ________keyword is used for defining a class in Python?
a) class b) object
c) return d) none
Q.10 Which of the following are greedy match quantifiers?
a) ‘*’ b) ‘+’
c) ‘?’ d) all above
Q.11 Python is which type language:-
a) Object Oriented b) Procedure oriented
c) Schema Oriented d) None of the above
Q.12 How to create a variable in Python with value 34?
a) int a=34 b) a =34
c) integer a = 34 d) None
Q.13 How to add a multi-line comment in Python?
a) /*This is comment b) !! This is comment
c) // This is comment d) '''This is comment'''
Q.14 Name of the operators which operate on bits:-
a) Bitwise Operators b) Exponentiation Operator
c) Identity Operator d) Membership Operators
Q15 Name the thing which is not a core data type.
a) List b) Tuples
c) Dictionary d) class
Q.16 The extension of a Python module is______.
a) .py b) .mod
c) .pyy d) None of the above
Q.17How to align a string centrally in Python?
a) align () method b) center () method
c) fill () method d) None of the above
Q.18 The developer of Python is______.
a) Denis Ritchie b) Guido Van Rossum
c) Peter Norton d) John Backus
Q.19 The following is an example of an invalid variable?
a) xyz_1 b) 1st
c) foo d) _qwe
Q.20 How to correctly create a function in python?
a) demoFunction() b) def demoFunction()
c) function demoFunction() d) void demoFunction()
Q.21How to access a value in Tuple?
a) mytuple (1) b) mytuple [1]
c) mytuple {1} d) None of the above
Q.22 Name the operator used in Python to raise numbers to the power?
a) Bitwise Operators b) Exponentiation Operator
c) Identify Operator d) Membership Operators
Q.23 Name the thing which represents a key-value pair in Python?
a) Tuples b) Lists
c) Dictionary d) all of the above
Q.24 Name the thing which does not allow duplicate values.
a) Set b) lists
c) Tuples d) None of the above
Q.25 Indentation is compulsory in Python. (True)
Q.26 Is Python is an object-oriented language? (True)
Q.27 Looping is used to execute the statement again and again. (True)
Q.28 Functions in Python will always return a value. (True)
Q.29 Python is a case sensitive language. (True)
Q.30 List allows duplicate values. (True)
Q.31 Python Tuples are faster than lists?(True)
Q.32 The function which converts all characters of a
string to lowercase is lower().
Q.33 OOPS stands for Object Oriented Programming.
Q.34 upper() string method converts all the character in upper case.
Q.35 re module is used for regular expression.
Q.36 The words having a special meaning in Python are
known as Keywords.
Q.37 Python Language was developed by Guido van Rossum.
Q.38 The return keyword is used in Python for end the execution of the
function call and "returns" the result.
Q.39 == is equality operator.
Q.40 % method is used for formatted specifiers.

SECTION-B
Note:- Objective type questions.
Q.1 Give the purpose of input function.
Ans:- The input function allows we to ask a user to type some aruments
into the program and to save that aruments into a variable that the program
can process.
Q.2 Write the statement import all the functionality of one module
to another module.
Ans:- import module_name
Q.3 Write any two common exception handled in Python.
Ans:- NameError , EOFError , ArithmeticError , etc.
Q.4 Define class.
Ans:- A class is a user-defined blueprint or prototype from which objects are
created.
Syntax:- class ClassName:
# Statement
Q.5 The Data type which is used to implement the keyvalue pair in Python.
Ans:- Dictionaries.
Q.7 The module that contains trigonometric and log arithmetic
functions is.
Ans:- math module.
Q.8 Name the error that occurs when a number is
divided by zero.
Ans:- ZeroDivisionError.
Q.9 Name the operator that is used to compare two operands and check them
for equality?
Ans:- Equality operator ==
Q.11 The elements of a list can be accessed by using which operator.
Ans:- Slice Operator [].
Q.12 The variables declared outside of a function have scope.
Ans:- Global variable.
Q.13 Name the module in Python which supports regular expression?
Ans:- math , sys , calender , etc.
Q.14 Write the character which is used for searching from the end.
Ans:- $
Q.15 Write the statement for opening a file c:/scores.txt for reading?
Ans:- var=open("c:/scores.txt","r")
Q.16 What is a compiler?
Ans:- A compiler is a special program that translates a programming language's
source code into machine code, bytecode or another programming language.
Q.17 What are environment variables?
Ans:- An environment variable is a dynamic-named value that can affect the
way running processes will behave on a computer. It will be declared outside
the programe.
Q.18 What is the Sys Module?
Ans:- The sys module in Python provides various functions and variables that
are used to manipulate different parts of the Python runtime environment.
Q.21 Give an example of an arithmetic exception.
Ans:- ZeroDivisionError.
Q.22 What is the use of print function?
Ans:- The print() function prints the specified message to the screen, or other
standard output device.
Q.24 What are scalar objects in Python?
Ans:- Scalar objects are used for singular variables that are not part of a table or
an array.
Q.25 What are dynamic types?
Ans:- Dynamic typing means that the type of the variable is determined only
during runtime.
Q.26 Write down the syntax of for loop.
Ans:- Syntax:-
for iterator_var in sequence:
#statements(s)
Q.28 What is the use of PYTHONHOME environment variable?
Ans:- PYTHONHOME environment variable is used to set the default location of
the standard Python libraries.
Q.29 What is the use of dir function?
Ans:- The dir() function returns all properties and methods of the specified
object, without the values.
Q.32 Explain the concept of Greedy Matches.
Ans:- A greedy match means that the regex engine (the one which tries to find
your pattern in the string) matches as many characters as possible.
Q.33 What are quantifiers?
Ans:- A quantifier has the form {m,n} where m and n are the minimum and
maximum times the expression to which the quantifier applies must match.

Section-C
Note: Short answer type questions.
Q.1 Briefly explain History and Versions of Python?
Q.2 Explain input and print function with example in Python.
Q.3 Difference between break and continue statement.
Q.4 Define set. Explain how it is created in Python?
Q.5 Difference between list and tuple.
Q.6 What is First class function? Write any four properties of first class function ?
Q.7 What is sys module? Write down uses of sys moduleb in Python.
Q.8 Briefly explain the following statement with syntax
a) Try
b) catch
Q.9 Explain various mode of opening a file in Python.
Q.10 What do you mean by constructor in Python? Explain its type.
Q.11 Explain the concept of Quantifiers in Python.
Q.12 What is splitting? Explain with example?
Q.13 What are exceptions in Python? List the common
exception in Python.
Q.14 Explain any four keywords or reserved words of Python.
Q.15 Explain for loop of Python.
Q.16 Explain the usage of is, not and in operators of Python.
Q.17 Explain the lambda function with the help of a suitable example.
Q.18 Write a program in Python to find the largest numbers among three
numbers.
Q.19 Write a program in Python to check if a number is prime or not.
Q.20 Write a program to read the contents of a file.
Q.21 Write a program to write the contents of a file.
Q.22 Define variable and what are the rules for creating
variables in Python.
Q.23 Define the module and how it is imported into a Python file.
Q.24 Explain assert statement with an example.
Q.25 What are the benefits of using functions in Python?
Q.26 Explain substituting in Regular expression.
Q.27 What do the following string methods do:-
a) lower()
b) count ()
c) replace ()
Q.28 Distinguish between C++ and Python.
Q.29 What are the key features of Python?
Q.30 Differentiate b/w mutable and immutable objects with example.
Q.31 What are container data types? Explain.
Q.32 Explain the various numeric data supported by Python in brief.
Q.33 Explain Dictionary and how it is created in Python.
Q.34 Explain the usage of math module with example.
Q.35 Describe any four List function.

Section-D
Note: Long answer type questions.
Q.1 Explain different type of operators used in Python with example.
Q.2 Write short notes with example on:-
a) map()
b) filter()
c) lambda ()
d) closures ()
Q.3 What is class and object? How they are implemented in Python explain with
examples?
Q.4 Explain the various types of parameters passing in
Python. justify you answer with sample programs.
Q.5 List and explain different arithmetic operators of Python with their
precedence and associativity.
Q.6 What is a regular expression? Explain different functions that can be used in
regular expressions.
Q.7 What is a file? Explain methods to open, close, read and write files in Python.
Q.8 Describe inheritance and explain the various types of python inheritance with
the help of suitable examples.

You might also like