0% found this document useful (0 votes)
18 views9 pages

Viva Voce

Sher

Uploaded by

a.solankii2007
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)
18 views9 pages

Viva Voce

Sher

Uploaded by

a.solankii2007
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/ 9

SHIVALIK PUBLIC SCHOOL

COMPUTER SCIENCE
BOARD VIVA VOCE QUESTIONS
1. Who developed Python?
Ans. Guido van Rossum, a Dutch programmer, developed Python in 1991.

2. What is Python and what are its uses?


Ans. Python is a programming language with objects, modules, threads, exceptions and automatic memory
management. The benefits of Python are that it is simple and easy, portable, extensible, has built-in data
structures and is open source.

3. What are the two modes of working in Python?


Ans. Two ways to use the Python interpreter are:
(i)Interactive mode (ii) Script mode

4. How is Python interpreted?


Ans. Python is an interpreted language. Python program runs directly from the source code. It converts
the source code that is written by the programmer into an intermediate language, which is again translated
into machine language that has to be executed.

5. What is the smallest element of Python coding termed as?


Ans. Tokens in Python

6. Differentiate between call by value and call by reference.


Ans. In the event that you pass arguments like whole numbers, strings or tuples to a function, the passing is
like call by value because you cannot change the value of the immutable objects being passed to the
function. Passing mutable objects, however, can be considered as call by reference because when their
values are changed inside the function, it is also reflected outside the function.

7. Identify and write the name of the Python module to which the following functions belong:
(a ceil() (b) floor() (c) randint()
)
(d dump() (e) sqrt() (f) Factorial
)
An (a math module (b) math module (c) random
s. ) module
(d pickle module (e) math module (f) math module
)

8. What type of objects can be used as keys in dictionaries?


Ans. Only immutable type objects (i.e., Numbers, Strings, Tuples) can be used as keys in dictionaries.

9. What is pickling and unpickling?


Ans. The pickle module accepts any Python object and converts it into a string representation and dumps it
into a file by using dump() function. This process is called pickling. The process of retrieving original Python
objects from the stored string representation is called unpickling.

10. How is memory managed in Python?


Ans. Python memory is managed by Python private heap space. All Python objects and data structures are
located in a private heap. The programmer does not have access to this and the interpreter takes care of this
Python private heap.
• The allocation of Python heap space for Python objects is done by Python memory manager. The core API
gives access to some tools for the programmer to code.
• Python also has an inbuilt garbage collector which recycles all the unused memory, frees up memory and
makes it available to the heap space.

11. State the use of the split() function in Python.


Ans. The split() function breaks a string into shorter strings using a defined separator. It gives a list of all words
present in the string.

12. Can keywords be used as identifiers in Python?


Ans. No, keywords are the reserved words in Python and can’t be used as identifiers or variable names.

13. What are the built-in data types that Python provides?
Ans. There are mutable and immutable data types of Python built-in data types. Mutable built-in data types
offered by Python are:
• List
• Sets
• Dictionaries
Immutable built-in types are:
• Strings
• Numbers

14. What is pass in Python?


Ans. pass means no-operation Python statement or, in other words, a placeholder in compound statement where
there should be a blank left and nothing should be written there.

15. What is negative index in Python?


Ans. Python sequences can be indexed using both the positive and negative numbers. For positive index, 0 is the
first index, 1 is the second index, so on and so forth. For negative index, (–1) is the last index and (–2) is the
second-last index and so on.

16. How can you convert a number into a string?


Ans. In order to convert a number into a string, use the inbuilt function str(). If you want an octal or
hexadecimal representation, use the inbuilt function oct() or hex().

17. Which operator checks a value’s presence in a list of values?


Ans. in

18. In file handling, what does the terms ‘r’, ‘a’ stand for?
Ans. ‘r’ stands for read and ‘a’ stands for append.

19. What do you understand by module and package in Python?


Ans. In Python, module is the way to structure a program. Each Python program file is a module which imports
other modules like objects and attributes.
The folder of a Python program is a package of modules. A package can have modules or sub-folders.

20. What are the rules for local and global variables in Python?
Ans. Local variables: If a variable is assigned a new value anywhere within a function’s body, it is assumed to be
local.
Global variables: Those variables that are only referenced inside a function are implicitly global.

21. How do you access and modify a global variable in Python?


Ans. Global variables are accessible throughout the program and inside every function. However, to change the
value of the global variable from within a function, we use global keyword.
22. Explain how to delete a file in Python.
Ans. A file can be deleted by using a command os.remove(filename) or os.unlink(filename).

23. Explain how you can generate random numbers in Python.


Ans. To generate random numbers in Python, we need to import command as:
import random random.random()
This returns a random floating-point number in the range [0.0,1.0).

24. Mention five benefits of using Python.


Ans. (a) Python comprises a huge standard library for most internet platforms like email, HTML, etc.
(b) Python does not require explicit memory management as the interpreter itself allocates memory to
new variables and frees them automatically.
(c) It provides easy readability due to the use of square brackets.
(d) It is easy to learn for beginners.
(e) Having built-in data types saves programming time and effort from declaring variables.

25. What is the use of // operator in Python?


Ans. It is a Floor Division operator which is used for dividing two operands with the result as quotient,
showing only digits before the decimal point. For instance, 10//5 = 2 and 10.0//5.0 = 2.0. If one of the
operands is negative, the output is floored, for example, –10//3 = –4.

26. Write any two rules of naming an identifier in Python.


Ans. (i) An identifier name must start with a letter or the underscore character.
(ii) Identifier name must not be any reserved word or keyword.

27. What are literals in Python?


Ans. Python literals are fixed numeric or non-numeric value which can be defined as number, text or other
data which can be assigned to a variable or constant. For example: 30,–8.97,”Learning”, etc.
There are 5 types of literal available in Python:
• String literals • Numeric literals • Boolean literals
• Special literals • Collection literals

28. Explain Python functions.


Ans. A function is a set of instructions or a block of code that is written once and can be called and executed
whenever required in the program. There are two categories of functions in Python:
• Built-in functions
• User-defined functions

29. What are the three types of files in Python?


Ans. The three types of files in Python are Text files, Binary files and CSV files.

30. In text file, each line is terminated by which special character?


Ans. EOL (End of Line)

31. Which command is used to read “n” number of characters from a file using the file object <file>?
Ans. read(n)

32. What is the difference between actual parameter/argument and formal parameter?
Ans. Actual argument/parameter: The values that are passed in a function cell are called actual parameters,
e.g.,
print(sum(3,5)). Here 3 and 5 are actual parameters.
Formal argument/parameter: The variables that are specified in a function definition, e.g., def sum (a, b):. Here a
and b are formal parameters.

33. Name the different file processing modes supported by Python.


Ans. Python provides three modes to work with files:
• Read-only mode • Write-only mode • Read-Write mode

34. What are tell() and seek() functions in Python?


Ans. The tell() function returns the current file position of file handle.
The seek() function is used to change the position of the file handle to a specified position.

35. What is the difference between read() and readlines() method?


Ans. The read() method reads the entire file and returns in the form of a string.
The readlines() method reads all the lines and returns each line as list of strings.

36. Which mode in file opening statement results or generates an error if the file does not exist?
Ans. r+

37. Which module is required to use the built-in function dump()?


Ans. pickle

38. What is/are the basic I/O (input-output) streams in file?


Ans. Standard Input, Standard Output and Standard Errors

39. What is an operator in Python?


Ans. An operator is a particular symbol which is used on some values and produces an output as a result.
For example, 10 + 30 = 40
Here, “+” and “=” are operators.
40. What are the different types of operators in Python?
Ans. Following is a list of operators in Python:
• Arithmetic Operators • Relational Operators • Assignment Operators
• Logical Operators • Membership Operators • Identity Operators

41. What is a Dictionary in Python?


Ans. Dictionary is an important built-in data type in Python. It defines one-to-one relationship between keys and
values. Dictionaries contain a pair of keys and their corresponding values.
Dictionaries are indexed by keys.

42. What is the use of help() function in Python?


Ans. The help() function is used to display the documentation string and also enables us to see the help related to
modules, keywords, attributes, etc.

43. Which package must be imported in Python to create a database connectivity application?
Ans. mysql.connector

44. Which function will return all rows from the ResultSet in the form of tuple containing records?
Ans. fetchall()

45. Write a statement to import module for MySQL connectivity with Python.
Ans. import mysql.connector

46. In the stack, if a user tries to remove element from the empty stack, what is the situation called?
Ans. Underflow of Stack
47. How does Python do compile-time and run-time code checking?
Ans. In Python, some amount of coding is done at compile-time but most of the checking such as type, name,
etc., is held up until the code execution. Consequently, if the Python code references a user-defined function
that does not exist, the code will compile successfully. The Python code will fail only with an exception when
the code execution path does not exist.

48. Explain the use of try, except, raise and finally blocks.
Ans. The try, except and finally blocks are used in Python error-handling mechanism. Code is executed in the try
block until an error occurs. The except block is used to receive and handle all errors. Control is transferred to
the appropriate except block. In all cases, the finally block is executed. The raise may be used to raise your
own exceptions.

49. What is the purpose of PYTHONPATH environment variable?


Ans. PYTHONPATH has a role similar to PATH. This variable tells the Python interpreter where to locate the
module files imported into a program. It should include the Python source library directory and the directories
containing Python source code.

50. What is the difference between lists and tuples?


Ans.
Lists Tuples
Lists are mutable, i.e., they can be Tuples are immutable (tuples are lists which can’t be
edited. edited).
Lists are slower than tuples. Tuples are faster than lists.
Syntax: Syntax:
list1=[10,'Python',44.5] tup1=(10,'Python',44.5)

51. How will you reverse a list?


Ans. list.reverse()− Reverses items of list in place.

52. What is a string in Python?


Ans. A string in Python is a sequence of alphanumeric characters enclosed in single and double quotes. They are
immutable objects. It means that they don’t allow modification once they are assigned a value. Python
provides several methods such as join(), replace() or split() to alter strings.

53. Why is the return keyword used in Python?


Ans. The purpose of a function is to receive the inputs and return some output. The return is a Python
statement which we can use in a function for sending a value back to its calling function.

54. When should you use the ‘break’ statement in Python?


Ans. Python provides a break statement to exit a loop. Whenever the break hits the code, the control of the
program immediately exits from the body of the loop. The break statement in a nested loop causes the
control to exit from the inner iterative block.

55. What is a tuple in Python?


Ans. A tuple is a collection of type data structure in Python which is immutable. Tuples are similar to
sequences just like the lists. However, there are some differences between a tuple and a list—the former
doesn’t allow modifications but the latter does.
Also, tuples use parentheses for enclosing but lists have square brackets in their syntax.

56. Explain the following results retrieval methods with examples:


(i) fetchone() (ii) fetchall() (iii) fetchmany()
Ans. (i) fetchone(): The fetchone() method will return only one row from the result set in the form of tuple
containing a record.
(ii) fetchall(): The fetchall() method will return all the rows from the result set in the form of a tuple
containing the records.
(iii) fetchmany(n): The fetchmany(n) method will return only the specified n number of rows from the
result set in the form of a tuple containing the records.

57. Explain the use of ‘with’ statement.


Ans. In Python, generally ‘with’ statement is used to open a file, process the data present in the file, and also
to close the file without calling a close() method. The ‘with’ statement makes exception handling simpler by
providing cleanup activities.
The General form of with statement:
withopen("filename","mode")asfile_var:
<processing statements>

58. Differentiate between append() and extend() methods.


Ans. Both append() and extend() methods are methods of list. These methods are used to add elements at the
end of the list.
• append(element) – adds the single element at the end of the list which has called this method.
• extend(another-list) – adds the elements of another list at the end of the list which is called the extend
method.

59. To make the changes made by any SQL Queries permanently in database, which function is
used after execution of the query?
Ans. <connectionobject>.commit()

60. How can we get current directory using Python?


Ans. To get current directory in Python, we need to use os module. Then, we can get the location of the
current directory by using getcwd() function.

61. What is a CSV file?


Ans. CSV (Comma Separated Values) is a file format used to store tabular data, such as spreadsheet or
database in plain text where values are separated by comma.

62. Differentiate between file mode ‘w’ and ‘a’ mode with respect to Python.
Ans. ‘w’ mode opens a file for writing only. It overwrites the file if the file exists, otherwise it creates a
new file for writing.
‘a’ mode opens a file for appending at the end of the existing file, otherwise it creates a new file for writing.

63. What is the difference between del keyword and clear() function?
Ans. The difference between del keyword and clear() function is that while del keyword removes one
element at a time, clear function removes all the elements.

64. Give the syntax of seek() method while working randomly with Python Files.
Ans. file_object.seek(offset[,reference_point])

65. Write full form of the following terms:


(a) LAN (b) WAN
(c) MAN (d) SMTP
(e) TCP/IP (f) VoIP
(g) URL (h) HTTP
Ans. (a) LAN – Local Area Network (b) WAN – Wide Area Network
(c) MAN – Metropolitan Area Network (d) SMTP – Simple Mail Transfer Protocol
(e) TCP/IP – Transmission Control Protocol (f) VoIP – Voice over Internet Protocol
(g) URL – Uniform Resource Locator (h) HTTP – Hypertext Transfer Protocol
66. Differentiate between web browser and web server.
Ans. A web browser is a software used to access the internet, for example, Google Chrome, Microsoft Edge,
Mozilla Firefox, etc.
A web server is a software which entertains the request(s) made by a web browser, for example, Apache,
Microsoft IIS.

67. Identify the protocols:


(a) Used to send emails
(b) Used to send voice, video and data over the internet
(c) It breaks down the original message into packets
(d) Used to login to a remote machine
(e) Used to exchange files over the internet
Ans. (a) SMTP (Simple Mail Transfer Protocol)
(b) VoIP (Voice over Internet Protocol)
(c) TCP (Transmission Control Protocol)
(d) TELNET
(e) FTP (File Transfer Protocol)

68. Differentiate between Hub and Switch.


Ans. Hub is a networking device used to connect multiple computers and broadcast the message to all
computers connected to it. A Switch is also used to connect multiple computers in a network but Switch is an
intelligent hub as it transfers message only to the intended computer.

69. Give examples of guided and unguided mediums of data transmission.


Ans. Examples of Guided or Wired medium – Twisted pair cable, Co-axial wire, Optical fibre cable.
Examples of unguided or wireless medium – Radio waves, Microwaves, Infrared, Satellites.

70. Identify the network topology:


(a) Each node is connected to a single backbone cable.
(b) Each node is connected to a central device.
Ans. (a) Bus topology (b) Star topology

71. Define the following terms:


(a) Website (b) Web page
(c) Home page (d) Web server
Ans. (a) Website: A website is a collection of various web pages, images, videos, audios or other kinds of digital
assets that are hosted on one or several web servers.
(b) Web page: A web page is an electronic document/page designed using HTML. It displays
information in textual or graphical form. A web page can be static or dynamic.
(c) Home page: The first page of a website is known as home page, where all the links related to
other documents are displayed.
(d) Web server: A web server is a program that runs on a computer connected to the internet. It is a
server that stores web pages and responds to the requests made by web browsers.

72. Differentiate between IP address and MAC address.


Ans. IP (Internet Protocol) address uniquely identifies the devices on a network while MAC (Media Access
Control) address is used to identify the physical address of the computer. IP address is assigned by
ISP (Internet Service Provider) while MAC address is assigned by manufacturer.

73. Name the device used to connect dissimilar networks.


Ans. Gateway.
74. What is Primary key?
Ans. Primary key is a column or a combination of columns that uniquely identify a row in a relational table.

75. What is Candidate key?


Ans. All possible combinations of columns that can possibly serve as the primary key are called candidate keys.

76. What is Foreign key?


Ans. A combination of columns where values are derived from primary key of some other table is called the
foreign key of the table in which it is contained.

77. What is Alternate key?


Ans. A candidate key that is not serving as a primary key is called an Alternate key.

78. What is MySQL?


Ans. MySQL is an open-source RDBMS that relies on SQL for processing data in the database. The database
is available for free under the terms of General Public Licence (GPL).

79. What is RDBMS?


Ans. Relational Database Management System (RDBMS) facilitates access, security and integrity of data and
eliminates data redundancy, for example, MySQL, Oracle, Microsoft SQL Server, etc.

80. Differentiate between Drop and Delete command.


Ans. Drop command is used to delete tables, for example, Drop Table Orders;while Delete command is
used to delete rows of a table, for example, Delete from Student;

81. What do you understand by NOT NULL constraint?


Ans. This constraint ensures that the NULL values are not permitted on a specified column. This constraint can be
defined at the column level and not at the table level.

82. What is the significance of COUNT() function in MySQL?


Ans. It is used to count the number of non-null values in a given column or number of non-null rows in a table, for
example, Select Count (RollNo) from students;
If we use the asterisk, we get all rows, including nulls and duplicates, for example, Select Count(*) from
students;

83. How can we add a record and add a column in a table?


Ans. We can add a record by using INSERT INTO command and a column through the ALTER table command.

84. Differentiate between DDL and DML commands.


Ans. DDL (Data Definition Language) is used to change the structure of the table while DML (Data
Manipulation Language) is used to retrieve records from the table.
Examples of DDL commands are – ALTER , CREATE, DROP. Examples
of DML commands are – SELECT, INSERT INTO, DELETE

85. Give the necessary command to incorporate SQL interface within Python.
Ans. import MySQLdb

86. To establish a connection between Python and SQL database, connect() is used. Which argument(s)
may not necessarily be given while calling connect()?
Ans. database name

87. Which of the functions gives the result as a string when applied while reading contents from a
text file in Python?
Ans. read() and readline()

88. After executing any DML command from Python in Python-MySQL connectivity, which
method/statement is necessary to execute in order to make the changes permanent in MySQL?
Ans. commit()
89. Which function is used to open a connection with MySQL database from within Python using
mysql.connector package?
Ans. connect()

90. After establishing database connection, which database object is created so that the SQL query
may be executed through it to obtain result set?
Ans. cursor

You might also like