Computer Science Class XII CBSE Viva Questions
Computer Science Python Viva Questions
Single Page Viva Portal
Item 1
Computer Science Python Viva Questions for Class 12
Item 2
Congratulations on reaching the viva voce stage of your Class 12 computer science journey! As you prepare for this important examination, it’s essential to be well-versed in various aspects of computer science, including Python projects, database management systems, computer networks, and file handling in Python. In this guide, we present a detailed set of questions to help you thoroughly prepare for your viva.Machine Learning & Artificial Intelligence
Item 3
Computer Science Viva Questions for Class 12
Item 4
Python Project Based Questions
Item 5
Here are some potential questions that an examiner might ask during your viva voce for a Python project with MySQL connection:
Item 6
Project Overview:
Item 7
1. Explain the purpose of your project and its main features.
Item 8
Purpose of the Project:- The project aims to create a simple management system using Python and MySQL. It allows users to add, update, and retrieve product information from a centralized database.
Item 9
2. How did you decide on using Python for this project? What advantages does Python offer in this context?
Item 10
Choosing Python:- Python was chosen for its readability, extensive libraries, and ease of integration with MySQL. The simplicity of Python makes it ideal for rapid development, and its support for MySQL connectors simplifies database interactions.
Item 11
3. Describe the database schema you designed for your project.
Item 12
Database Schema:- The database schema includes tables for products, categories, and suppliers. Each product entry contains details such as ID, name, quantity, price, category, and supplier information.
Item 13
4. Explain the process of establishing a connection between your Python code and MySQL database.
Item 14
Database Connection:- I used the `mysql-connector-python` library to establish a connection. The connection details, including host, username, password, and database name, are configured in the script. The `connect()` function initiates the connection.
Item 15
5. How did you handle error handling and exception handling in your project?
Item 16
Error Handling:- I implemented try-except blocks to handle potential errors during database operations. This ensures that if there’s a connection error or a query fails, the program gracefully handles the situation and provides appropriate feedback.
Item 17
6. Discuss the security measures you implemented to protect the database connection and data.
Item 18
Security Measures:-To enhance security, I stored database credentials in a separate configuration file with restricted access. Additionally, input validation and parameterized queries were used to prevent SQL injection attacks.
Item 19
7. Can you explain the significance of SQL injection and how your project guards against it?
Item 20
SQL Injection Prevention:-SQL injection was mitigated by using parameterized queries. This ensures that user inputs are treated as data rather than executable code, preventing malicious SQL injection attempts.
Item 21
8. Walk through the steps involved in retrieving data from the database using Python.
Item 22
Retrieving Data:-Data retrieval involves executing SELECT queries based on user input. The results are fetched and displayed in the user interface or used for further processing within the program.
Item 23
9. Discuss the role of libraries or modules you used in your project, especially those related to database connectivity.
Item 24
Library Usage:-The `mysql-connector-python` library facilitated database interactions, while other standard libraries like `tkinter` were used for the graphical user interface. The combination of these libraries streamlined development.
Item 25
10. How did you handle data validation and sanitation to ensure the integrity of the data in the database?
Item 26
Data Validation:- Input data is validated to ensure it meets predefined criteria. For example, when adding a new product, the quantity and price must be numeric, and the product name should not be empty.
Item 27
11. Explain the techniques you employed for optimizing database queries in your project.
Item 28
Optimizing Database Queries:- Optimization involved indexing frequently queried columns and using efficient JOIN operations. Additionally, I avoided SELECT * and retrieved only the necessary columns to minimize data transfer.
Item 29
12. Describe any challenges you faced during the development of the project and how you overcame them.
Item 30
Challenges Faced:-One challenge was handling concurrent database access. I addressed this by implementing locks during critical sections of code to prevent data inconsistency. Additionally, debugging complex SQL queries posed challenges, which were overcome by using print statements and step-by-step analysis.
Item 31
13. Discuss the testing process for your project. How did you ensure the reliability of the code?
Item 32
Testing Process:-The testing process involved unit tests for individual functions and integration tests for the entire system. I created mock databases to simulate various scenarios, ensuring the robustness and reliability of the code.
Item 33
14. Elaborate on any future enhancements or features you would consider adding to your project.
Item 34
Future Enhancements:-Future enhancements could include implementing user authentication, refining the user interface for a more intuitive experience, and incorporating data analytics features for better decision-making.
Item 35
These are concise examples to get you started. When answering these questions, ensure you provide enough detail to demonstrate your understanding of the concepts and your project’s implementation.
Item 36
Providing specific examples and details from your project will enhance the authenticity of your answers during the viva voce.
Item 37
Be prepared to explain your thought process, coding decisions, and the overall architecture of your project. Good luck with your practical exam!
Item 38
Computer Science Viva Questions for Class 12
Item 39
In this article you will find some of the best viva questions form Python Programming that may be possible to be asked by the examiner in your practical examination. Here we collect more than 50 viva questions in python for the students of Computer Science and I.P. Students are advised to make a quick overview Computer Science Viva Questions for Class 12 before attending the CBSE Practical Examination which is scheduled in December-January in this session. Hope you will find this content helpful in getting maximum marks.
Item 40
1- What is Python?
Item 41
Ans. Python is a high-level, interpreted, dynamic, Object-Oriented Programming Language that supports GUI programming.
Item 42
2- Why is Python interpreted?
Item 43
Ans. Python is interpreted because the program is processed at runtime by the interpreter and you do not need to compile your program before executing it.
Item 44
3- Who developed Python?
Item 45
Ans. Python was developed by Guido van Rossum in the early nineties at the National Research Institute for Mathematics in the Netherlands.
Item 46
4- Why is Python easy to learn?
Item 47
Ans. Python has relatively few keywords, simple structure and a clearly defined syntax. This allows the student to understand and work easily in a relatively short period of time.
Item 48
5-Write any one feature of Python library.
Item 49
Ans. Python library is very portable and cross-platform compatible with UNIX, Windows and Macintosh.
Item 50
6- Is Python a compiler language or an interpreter language?
Item 51
Ans. The normal execution of Python program is interpreted. However, subsets of the language can be compiled.
Item 52
7- Python is a free and open-source language. What do you understand by this feature?
Item 53
Ans. That Python is a free and open-source language signifies that we do not ave to pay anything to download it. Also, being an open-source language, its source code is also available if we wish to modify it.
Item 54
8- State some distinguishable features of Python
Item 55
Ans. Python is a modern, powerful, interpreted language with objects, modules, exceptions (or interrupts) and automatic memory management. It was introduced to the world by Guido van Rossum in the year 1991.
Item 56
Salient Features of Python are:
Item 57
(i) Simple and Easy: Python is a simple language that is easy to learn.
Item 58
(ii) Free/Open source: Anybody can use Python without the need to purchase a licence. High-level Language: Being a high-level language, it can be easily understood by the user without the need to be concerned with low-level details.
Item 59
(iii)Portable: Python codes are machine and platform-independent.
Item 60
(iv) Extensible and Embeddable: Python programs support usage of C/C++ codes. pre-written tools for programming,
Item 61
(v) Standard Library: Python standard library contains
Item 62
9- What are the two modes to work with python.
Item 63
Ans: (i) Interactive mode (ii)Script mode
Item 64
10- What is an expression?
Item 65
Ans: An expression is legal combination of symbols that represents a value.
Item 66
11- What is string?
Item 67
Ans: String is a sequence of characters.
Item 68
12- What is the use of ‘+’ operator in string?
Item 69
Ans: ‘+’ operator joins or concatenates the strings on both sides of the operator.
Item 70
13-What is the use of ‘*’ operator in string?
Item 71
Ans: ‘*’ operator creates a new string concatenating multiple copies of the same string.
Item 72
14- How many types of strings are supported in Python?
Item 73
Ans: Python allows two string types:
Item 74
i) Single line String- String that terminated in a single line.
Item 75
ii) Multiline String-String storing multiple lines of text
Item 76
15- What is a tuple?
Item 77
Ans: A tuple is an immutable sequence of values which can be of any type and are indexed by an integer.
Item 78
16- Differentiate between list and tuples.
Item 79
Ans: Tuples cannot be changed unlike lists, tuples use parentheses, whereas list use square brackets.
Item 80
You Should also check:
Item 81
Class 12 Practical File
Item 82
Class 12 Projects in Python for Practical Examination
Item 83
17- What is an argument? Give an example.
Item 84
Ans: An argument is data passed to a function through function call statement. For example, in the statement print (math.sqrt(25)) the integer 25 is an argument.
Item 85
18- Python has certain functions that you can readily use without having to write any special code. What types of functions are these?
Item 86
Ans: The pre-defined functions that are always available for use are known as Python’s built-in functions.
Item 87
Examples of some built-in functions are: input(), type(), int(), eval(), etc.
Item 88
19- What is Python module? What is its significance?
Item 89
Ans: A “module” is a chunk of Python code that exists in its own (.py) file and is intended to be used by Python code outside itself.
Item 90
Modules allow one to bundle together code in a form in which it can easily be used later. The Modules can be “imported” in other programs so the functions and other definitions in imported modules become available to code that imports them.
Item 91
20- What is the utility of the built-in function help()?
Item 92
Ans: Python’s built-in function help() is very useful. When it is provided with a program name or a module-name or a function-name as an argument, it displays the documentation of the argument as help. It also displays the string within its passed-argument’s definition. For example,
Item 93
>>>help (math)
Item 94
21- What is the difference between local variable and global variable?
Item 95
Local Variable
Item 96
1- It is a variable which is declared within Function or within a block.
Item 97
2- It is accessible only within the function /block program.
Item 98
Global Variable
Item 99
1- It is a variable which is declared outside all the functions.
Item 100
2- It is accessible throughout the program in which it is declared.
Item 101
22- Is return statement optional? Compare and comment on the following two return statements:
Item 102
return val
Item 103
The return statement is optional only when the function is void or we can say that when the function does not return a value. A function that returns a value must have at least one return statement. From the given two return statements, the statement:
Item 104
is not returning any value. Rather, it returns the control to caller along with empty value None. And the statement:
Item 105
return val
Item 106
is returning the control to caller along with the value contained in variable val.
Item 107
23- Distinguish between Java and Python.
Item 108
Ans: Java and Python can be distinguished on the following bases:
Item 109
(i) Python programs run slower than the Java codes, but Python saves much time and space. Python programs are 3 to 5 times smaller than Java programs.
Item 110
(ii)Python is a loosely-typed dynamic language as no time gets wasted in declaring variable types as in Java.
Item 111
(iii) Python is easier to learn than Java.
Item 112
24- What is the difference between a keyword and a variable?
Item 113
Ans. Keyword is a special word that has a special meaning and purpose. For example, int, float, for, if, elif, else, etc., are keywords. Keywords are reserved and are few.
Item 114
Variable is the user-defined name given to a value. Variables are not fixed/reserved. These are defined by the user but they can have letters, digits and a symbol underscore. They must begin with either a letter or underscore. For example, _age, name, result_1, etc., are the variable names in Python.
Item 115
25- What is a function? How is it useful?
Item 116
Ans. A function in Python is a named block of statements within a program.
Item 117
26- What is the difference between an expression and a statement in Python?
Item 118
S. No. Expression Statement
Item 119
1 An expression is a combination of symbols, operators and operands. Statement is defined as any programming instruction given in Python as per the syntax.
Item 120
2 An expression represents some value. Statement is given to execute a task.
Item 121
3 The outcome of an expression is always a value. Statement may or may not return a value as the result.
Item 122
4 For example, 3*7 + 10 is an expression print (“Hello”) is a statement.
Item 123
27- How many kinds of statements are there?
Item 124
Ans. Statements are categorized into three types:
Item 125
I) Empty statements,
Item 126
II) Simple statements, and
Item 127
III) Compound statements.
Item 128
28- What is the significance of an empty statement?
Item 129
Ans. An empty statement does nothing. In Python, an empty statement is a pass statement.
Item 130
29- Describe flow charts, decision tree and pseudo-code.
Item 131
Ans. Flow charts are diagrams that show the step-by-step solution to a given problem. A decision tree is a diagrammatic representation of possible outcomes of certain conditions. Pseudo-code is a simple and informal way of writing programming code in English. There are no standard rules to write Pseudo-code.
Item 132
30- What is the difference between break and continue statements?
Item 133
Ans. Break and continue are the jump statements, and can be used to alter the flow of loop. Break statement terminates the loop and resumes execution in the statement. Continue statement skips the rest of the code inside a loop for the current iteration.
Item 134
31- What is the purpose of ‘else’ in a loop?
Item 135
Ans. Looping statements can have an optional else block as well. The else part is executed if the items in the sequence do not match or when loop gets over.
Item 136
32. What is namespace in Python?
Item 137
Ans: A namespace is a naming system used to make sure that names are unique to avoid naming conflicts.
Item 138
33. What is PYTHONPATH?
Item 139
Ans: It is an environment variable which is used when a module is imported. Whenever a module is imported, PYTHONPATH is also looked up to check for the presence of the imported modules in various directories. The interpreter uses it to determine which module to load.
Item 140
34. What are python modules? Name some commonly used built-in modules in Python?
Item 141
Ans: Python modules are files containing Python code. This code can either be functions classes or variables. A Python module is a .py file containing executable code.
Item 142
Some of the commonly used built-in modules are:
Item 143
data time
Item 144
35. Is python case sensitive?
Item 145
Ans: Yes. Python is a case sensitive language.
Item 146
36. Is indentation required in python?
Item 147
Ans: Indentation is necessary for Python. It specifies a block of code. All code within loops, classes, functions, etc is specified within an indented block. It is usually done using four space characters. If your code is not indented necessarily, it will not execute accurately and will throw errors as well.
Item 148
37. What is the difference between Python Arrays and lists?
Item 149
Ans: Arrays and lists, in Python, have the same way of storing data. But, arrays can hold only a single data type elements whereas lists can hold any data type elements.
Item 150
38. What are functions in Python?
Item 151
Ans: A function is a block of code which is executed only when it is called. To define a Python function, the def keyword is used.
Item 152
39. How does break, continue and pass work?
Item 153
Break: Allows loop termination when some condition is met and the control is transferred to the next statement.
Item 154
Continue: Allows skipping some part of a loop when some specific condition is met and the control is transferred to the beginning of the loop
Item 155
Pass: Used when you need some block of code syntactically, but you want to skip its execution. This is basically a null operation. Nothing happens when this is executed.
Item 156
40. How do you write comments in python?
Item 157
Ans: Comments in Python start with a # character. However, alternatively at times, commenting is done using docstrings(strings enclosed within triple quotes).
Item 158
41. What is pickling and unpickling?
Item 159
Ans: 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. While the process of retrieving original Python objects from the stored string representation is called unpickling.
Item 160
42. How will you capitalize the first letter of string?
Item 161
Ans: In Python, the capitalize() method capitalizes the first letter of a string. If the string already consists of a capital letter at the beginning, then, it returns the original string.
Item 162
43. How will you convert a string to all lowercase?
Item 163
Ans: To convert a string to lowercase, lower() function can be used.
Item 164
44. What is the purpose of ‘is’, ‘not’ and ‘in’ operators?
Item 165
Ans: Operators are special functions. They take one or more values and produce a corresponding result.
Item 166
is: returns true when 2 operands are true (Example: “a” is ‘a’)
Item 167
not: returns the inverse of the boolean value
Item 168
in: checks if some element is present in some sequence
Item 169
45. What is a dictionary in Python?
Item 170
Ans: The built-in datatypes in Python is called dictionary. It defines one-to-one relationship between keys and values. Dictionaries contain pair of keys and their corresponding values. Dictionaries are indexed by keys.
Item 171
46. What are Python packages?
Item 172
Ans: Python packages are namespaces containing multiple modules.
Item 173
47. How can files be deleted in Python?
Item 174
Ans: To delete a file in Python, you need to import the OS Module. After that, you need to use the os.remove() function.
Item 175
48. What are the built-in types of python?
Item 176
Ans: Built-in types in Python are as follows –
Item 177
Integers
Item 178
Floating-point
Item 179
Complex numbers
Item 180
Built-in functions
Item 181
49. How to add values to a python array?
Item 182
Ans: Elements can be added to an array using the append(), extend() and the insert (i,x) functions.
Item 183
50. How to remove values to a python array?
Item 184
Ans: Array elements can be removed using pop() or remove() method. The difference between these two functions is that the former returns the deleted value whereas the latter does not.
Item 185
51. What are Python libraries? Name a few of them.
Item 186
Ans:Python libraries are a collection of Python packages. Some of the majorly used python libraries are – Numpy, Pandas, Matplotlib, Scikit-learn and many more.
Item 187
52. What is split used for?
Item 188
Ans:The split() method is used to separate a given string in Python.
Item 189
53. What is the maximum possible length of an identifier?
Item 190
Ans: Identifiers can be of any length.
Item 191
54. What are the common built-in data types in Python?
Item 192
Ans: The common built in data types in python are-
Item 193
Numbers– They include integers, floating point numbers, and complex numbers. eg. 1, 7.9,3+4i
Item 194
List– An ordered sequence of items is called a list. The elements of a list may belong to different data types. Eg. [5,’market’,2.4]
Item 195
Tuple– It is also an ordered sequence of elements. Unlike lists , tuples are immutable, which means they can’t be changed. Eg. (3,’tool’,1)
Item 196
String– A sequence of characters is called a string. They are declared within single or double quotes. Eg. “Sana”, ‘She is going to the market’, etc.
Item 197
Set– Sets are a collection of unique items that are not in order. Eg. {7,6,8}
Item 198
Dictionary– A dictionary stores values in key and value pairs where each value can be accessed through its key. The order of items is not important. Eg. {1:’apple’,2:’mango}
Item 199
Boolean– There are 2 boolean values- True and False.
Item 200
55. What is type conversion in Python?
Item 201
Ans: Type conversion refers to the conversion of one data type iinto another.
Item 202
int() – converts any data type into integer type
Item 203
float() – converts any data type into float type
Item 204
ord() – converts characters into integer
Item 205
hex() – converts integers to hexadecimal
Item 206
oct() – converts integer to octal
Item 207
tuple() – This function is used to convert to a tuple.
Item 208
set() – This function returns the type after converting to set.
Item 209
list() – This function is used to convert any data type to a list type.
Item 210
dict() – This function is used to convert a tuple of order (key,value) into a dictionary.
Item 211
str() – Used to convert integer into a string.
Item 212
complex(real,imag) – This function converts real numbers to complex(real,imag) number.
Item 213
56. What are Literals in Python and explain about different Literals
Item 214
Ans: A literal in python source code represents a fixed value for primitive data types. There are 5 types of literals in python-
Item 215
i) String literals– A string literal is created by assigning some text enclosed in single or double quotes to a variable. To create multiline literals, assign the multiline text enclosed in triple quotes. Eg.name=”Tanya”
Item 216
ii) A character literal– It is created by assigning a single character enclosed in double quotes. Eg. a=’t’
Item 217
iii) Numeric literals– They include numeric values that can be either integer, floating point value, or a complex number. Eg. a=50
Item 218
iv) Boolean literals– These can be 2 values- either True or False.
Item 219
57. What are negative indexes and why are they used?
Item 220
Ans: The sequences in Python are indexed and it consists of the positive as well as negative numbers. The numbers that are positive uses ‘0’ that is uses as first index and ‘1’ as the second index and the process goes on like that.
Item 221
The index for the negative number starts from ‘-1’ that represents the last index in the sequence and ‘-2’ as the penultimate index and the sequence carries forward like the positive number.
Item 222
The negative index is used to remove any new-line spaces from the string and allow the string to except the last character that is given as S[:-1]. The negative index is also used to show the index to represent the string in correct order.