0% found this document useful (0 votes)
6 views4 pages

Important Viva questions

The document lists important viva questions related to Python programming, covering topics such as language translation, data types, functions, file handling, and error types. It provides concise answers to each question, explaining concepts like mutable vs immutable types, slicing, comments, variable scope, and file operations. Additionally, it discusses the significance of stack operations and exceptions in Python.

Uploaded by

ishaan agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Important Viva questions

The document lists important viva questions related to Python programming, covering topics such as language translation, data types, functions, file handling, and error types. It provides concise answers to each question, explaining concepts like mutable vs immutable types, slicing, comments, variable scope, and file operations. Additionally, it discusses the significance of stack operations and exceptions in Python.

Uploaded by

ishaan agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Important Viva questions:

1. Which language translator is used by python?


o Interpreter
2. What are the built-in data types available in python?
o Numbers, Strings, Lists, Tuples, Dictionaries
3. How python interpreter interprets the code?
o Python interpreter interprets the code line by line.
4. Name a few mutable data types of python.
o Lists, Sets, and Dictionaries
5. Name a few immutable data types of python.
o Strings, Tuples, Numeric
6. What is slicing in python?
o Python slicing is a statement of python that extracts a list of
elements from the given sequence in the range of start and
stop values with step value intervals.
7. What are comments in python?
o Python comments are non-executable text written in the python
program to give a description for a statement or group of
statements.
8. What is the difference between / and //?
o / is used for division, // is used for floor division
o / returns float as answer whereas // returns integer as answer
o / gives you the number with decimal places whereas // gives
you only integer part
9. What is the difference between append() and extend() methods?
o append() is used to add an element to the list to the last.
o extend() is used to add multiple elements to the list.
10. What is a function?
o A function is a subprogram and a smaller unit of a python
program consists of a set of instructions and returns a value.
11. Does every python program must return a value?
o No, not every python program returns a value.
12. What are the parts of a function?
o A python function has the following parts:
 Function header – Starts with def keyword followed by
function name and parameters
 Function body – Block of statements/instructions that
define the action performed by the function, indentation
must be followed
 Function caller statement – writing function name
including parameter values
13. What are the needs of function in the python program?
o Easy program handling
o Reduce the size of the program
o Reduce the repeated statements
o Ambiguity can be reduced
o Make program more readable and understandable
14. What is indentation? Explain its importance in two lines.
o Indentation refers to white spaces added before each line of the
code.
o In python, it detects the block of code.
o It also makes the program more readable and presentable.
o It organizes the code of blocks in a good manner.
15. What are the comments? Explain the role of comments in
the python programs?
o Comments are non-executable parts of python programs.
o You can write a comment for the description or information
related to statements, basic details of programs etc.
o There are two types of comments:
 Single-Line: These comments written for explaining single
line comments, begins with #
 Multi-Line: These comments written for explaining multi-
line comments, begins and ends with ”’ triple quotes
16. Which three types of functions supported by python?
o Python supports the following three types of functions:
 Built-in Functions
 Functions defined in modules
 User-defined functions
17. What are parameters and arguments in python programs?
o Parameters are the values provided at the time of function
definition. For Ex. p,r and n.
o Arguments are the values passed while calling a function. For
Ex. princ_amt, r, n in main().
18. What do you mean by python variable scope?
o The python variable scope refers to the access location of the
variable defined in the program.
o A python program structure has different locations to declare
and access the variable.
o There are two scopes of variables in python:
 Local Scope
 Global Scope
19. What is the local and global scope variable?
o The variable which is declared inside a function and can be
accessible inside a function is known as local variable scope.
o The variable declared in top-level statements of the python
program is called a global variable scope, it is accessible
anywhere in the program.
20. Name few commonly used libraries in python.
o Standard library
o Numpy Library
o Matplotlib
o SciPy
21. What are the two ways to import modules?
o You can import modules in python using these two ways:
 import <modulename>
 from <module> import <object>
22. What is a file?
o A file is a stream of bytes stored on secondary storage devices
having an extension.
23. What are the different modes of opening a file?
o The different modes of opening a file are as follows:
 r,w,a,r+,w+,a+,rb,wb,ab,rb+,wb+,ab+
24. If no mode is specified in open() function, which mode will
be considered?
o r
25. What is the difference between “w” and “a” mode?
o “a” mode adds the content to the existing file whereas “w” mode
overwrites the contents into the file.
26. What is the difference between readline() and readlines()
function?
o readline() function reads the content of the text file and returns
the content into the string whereas readlines() function reads
the content of the text file and returns the content into the list.
27. Are CSV files and Text Files same?
o CSV files and Text Files are same in storage but csv file stores
the data separated by a delimiter.
28. What is pickling?
o Pickling refers to the process of converting python object
hierarchy into a byte stream to write into a binary file.
29. What is unpickling?
o It is the process of converting the byte stream back into an
object hierarchy.
30. Which module is required to handle binary files?
o pickle
31. Name the functions used to read and write data into binary
files.
o pickle.dump(list_object, file_handle)
o pickle.load(file_object)
32. How to avoid reading file errors in binary file?
o By using exception handling with try and except blocks
33. What is the significance of tell() and seek() functions?
o tell() function returns the current file position in a file
o seek() function change the current file position
34. What are the operations can be performed on the stack?
o Push
o Pop
o Peep or Peek
35. Which principle is followed by stack?
o LIFO (Last in First Out)
36. Name any three applications of stack.
o Call history on mobile
o Browser history
o Undo and redo commands
o CD/DVD tracks
o Books on the tables
37. What is an exception in python?
o An error or unusual condition that occurs in the program that
causes abnormal termination of the program or crash of the
python program is called an exception.
38. Tell me the three basic types of errors that occur
in Python.
o Syntax Errors
o Logical Errors
o Run-Time Errors

You might also like