Python Viva Questions
PYTHON VIVA QUESTIONS
Python Viva Questions
CLICK FOR CLASS 12 COMPUTER SCIENCE PRACTICAL QUESTION PAPER (SOLVED)
Q1. What is Python?
Ans. Python is an open source, platform independent, high level and interpreted language.
Q2. Name two modes of Python.
Ans. Interactive Mode and Script Mode
Q3. Write Full Form of IDLE
Ans. Integrated Development Learning Environment
Q4. In which mode we get result immediately after executing the command?
Ans. Interactive mode
Q5. What do you mean by comments in Python?
Ans. Non executable lines are called Comments
Python Viva Questions
Q6. Which symbols are used for single line comments and multiple line comments?
Ans. # symbol
Q7. What do you mean by variable?
Ans. Named storage location of value is called variable
Q8. Write code to find the address of variable ‘x’
Ans. id command is used to find the address of variable for example, to find the address of variable ‘x’ code is >>>id(x)
Q9. What do you mean by data type?
Ans. Data type refers to the type of value used for example integer, float string etc
Q10. Name five primitive data type in python.
Ans. Five primitive data types are : Numbers, String, List, Tuple and Dictionary
Python Viva Questions
PYTHON VIVA QUESTIONS
CLICK FOR CLASS 12 COMPUTER SCIENCE PRACTICAL QUESTION PAPER (SOLVED)
Q11. Which method is used to accept data from the user?
Ans. input( ) method
Q12. Write three numeric data type in python.
Ans. Integer, Floating Point and Complex
Q13. Name three sequential data types in python.
Ans. List, tuple and String
Q14. Which data type store the combination of real and imaginary numbers?
Ans. Complex
Q15. Write the output of the following: >>> 4.7e7 >>> 3.9e2
Ans. 47000000 390
Python Viva Questions
Q16. Write the output of the following :
>>> (75 > 2 **5)
>>> (25 != 5 *2)
Q17. Write the code to display all keywords in python.
Ans import keyword print(keyword.kwlist)
Q18. Write the output of the following
>>> str = "Informatics"
>>>str[3] = 'e'
>>> print(str)
Ans. Type Error
Q19. What do you mean by Escape sequence?
Ans The sequence of characters after backslash is called escape sequence.
Q20. What is None data type?
Ans. This data type is used to define null value or no value. for example m = none, Now the variable ‘m’ is not pointing to any value, instead it is pointing to none.
Python Viva Questions
Q21. What do you mean by Operator?
Ans. Operators are special symbols which perform a special task on values or variables. Same operator can behave differently on different data types.
Q22. What is the output of 2 % 5?
Ans. 2
Q23. What is the difference between ‘=’ and ‘==’ operator?
Ans. ‘ = ‘ is an assignment operator while ‘==’ is a comparison operator.
Q24. What is the difference between ‘a’ and “a” in python?
Ans. No difference as String can be enclosed in Single or Double quotes.
Q25. What is the difference between ‘/’ and ‘//’ operator?
Ans. Division operator(/) return the quotient in decimal while Floor Division Operator(//) returns quotient as integer.
for example:
>>> 5 / 2 returns 2.5
>>> 5 // 2 returns 2
Python Viva Questions
Q26. Give an example of infinite loop.
Ans.
while True:
print("A")
Q27. What is the purpose of break statement?
Ans. break statement is used to forcefully terminate the loop even the condition is True.
Q28. Write the output of the following : >>> x = 8 >>> x = 5 >>> print (x + x)
Ans. 10
Q29. Identify the invalid variable names from the following and specify the reason also. a) m_n b) unit_day c) 24Apple d) #sum e) for f) s name
Ans.
24apple : Variable can not start with number #sum : Variables can not start from special character. for : Keyword can not be used as variable s name : Spaces are not allowed in variable names
Q30. What do you mean by binary and unary operators? Give one example of each.
Ans. Binary operators work on two or more operands like Division (+), Multiplication (*). 2 / 3 4 * 3 Unary operators work only on one operand like Subtraction (-) -9 -7
Python Viva Questions
Q31. Write the name and purpose of the following operators. // % **
Ans. // : Name of Operator is Floor Division . It is used to find the integer part of the quotient when one number is divided by other % : Name is Modulus or Remainder Operator . It is used to find the remainder when one number is divided by other ** : Name is Exponent. It is used to find the power of a number like 2**3 will give result 8.
Q32. What is the difference between eval() and int() function?
Ans. eval( ) function return error on passing integer argument while int( ) function does not return error. for example : print(eval(12)) returns error print(int(12)) returns 12
Q33. What is the difference between Lists and Tuples?
Ans.
Lists Tuples List are mutable Not Mutable Elements enclosed in Square brackets Elements enclosed in parenthesis
Python Viva Questions
Q34. Write the code to reverse a list named L1.
Ans. L1.reverse( )
Q35. What is string in python?
Ans. Strings are contiguous series of characters enclosed in single or double quotes. Python doesn’t have any separate data type for characters so they are represented as a single character string.
Python Viva Questions
Q36. What do you mean by Traversing String in Python?
Ans. It means accessing all the elements of the string one by one using index value.
Q37. What do you mean by Replicating String?
Ans. It refers to making multiple copies of same string.
Q38. What is String slicing?
Ans. String slicing is to get a piece of Substring from Main string.
Q39. What is the purpose of Try and Except in Python?
Ans. Try and Except are used in Error/Exception handling in Python. Code is executed in the Try block and Except block is used to accept and handle all errors.
Q40. What is append( ) function in reference to list?
Ans. append( ) function simply add an element at the end of the list.
Python Viva Questions
Q41. Can we print only keys of a dictionary?
Ans. Yes by using keys( ) method.
Q42. How can you print only keys of a dictionary without using keys( ) method?
d = {1 : “A”, 2 : “B”, 3 : “C”}
Ans.
d = {1 : "A", 2 : "B", 3 : "C"}
for i in d:
print(i)
Q43. What is the difference between actual argument and formal argument?
Ans. The values which are used in function call are called actual argument while the variables used in function definition are called formal argument.
Q44. Name the four types of actual arguments in python.
Ans. The four types of actual arguments in python are:
Positional arguments
Default arguments
Keyword arguments
Variable length arguments
Q45. What is argument?
Ans. An argument is a value that is passed to the function when it is called.
Python Viva Questions
Q46. What is the meaning of Scope of Variable?
Ans. Scope of variable refers to the part of program where it is accessible.
Q47. What is the difference between global and local variable?
Ans. Global variable can be accessed inside or outside the function while local variable can be accessed only inside the function where it is declared.
Q48. What is Recursion?
Ans. Recursion is a method in which a function calls itself in its body.
Q49. Define module in python.
Ans. A module is a file which contains definition of various methods/functions.
Q50. Name any two built in module.
Ans. math module, random module and statistics module etc’
Python Viva Questions
Q51. Which module is to be imported for sqrt( ), mean( ) and load()functions.
Ans. math module for sqrt( ), statistics module for mean( ) and pickle module for load( ).
Q52. What is the difference between Text file and Binary File.
Ans.
Text File Binary File These files can be read by human directly These files can not be read by humans directly. Each line is terminated by a special character , known as EOL No delimiter for a line Processing of file is slower than binary file Processing of file is faster than text file
Python Viva Questions
Q53. Name the function which is used to open or close file in python.
Ans. open( ) function is used to open file while close( ) is used to close the file.
Q54. Name three modes of opening a file.
Ans. Read, Write and Append mode
Q55. What is the difference between read( ) and read(n) method?
Ans. read( ) method will read all content from the file while read(n) method will read first n characters from file.
Python Viva Questions
Q56. What is the difference between readline( ) and readlines() method?
Ans.
readline() : This function will read one line at a time from the file
readlines() : This function is used to read all the lines from the file.
Q57. What does the readlines( ) method returns?
Ans. This method will return a list of strings, each separated by \n.
Q58. What is the difference between write( ) and writelines( ) method?
Ans. write(string) : This method takes a string as parameter and write the same string into our file.
writelines() : This method is used for writing the sequence data type like list, tuple or string into a file.
Q59. Expand FIFO.
Ans. First In First Out
Q60. Expand LIFO
Ans. Last In First Out
CLICK FOR CLASS 12 LATEST COMPUTER SCIENCE PRACTICAL QUESTION PAPER (SOLVED)
Python Viva Questions
Disclaimer : I tried to give you the correct answers of “Python Viva Questions ” , but if you feel that there is/are mistakes in the answers of “Python Viva Questions “ given above, you can directly contact me at csiplearninghub@gmail.com .
Class 12 Computer Science Sample Paper 2020-2021 .
Class 12 Computer Science Sample Paper Marking Scheme
Class 12 Computer Science Test Series
Like this: Like Loading...
Related