Viva Review
Viva Review
Viva Review
REVIEW OF PYTHON
VIVA QUESTIONS
Python IDLE can be used in two modes: Interactive mode and Script mode.
Python shell is an interactive interpreter. Python editor allows us to work
in script mode i.e. we can create and edit python source file.
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif',
'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda',
'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
NOTE: All these keywords are in small alphabets, except for False, None, True,
which are starting with capital alphabets.
1
Review of Python | Vineeta Garg
6. What is a variable?
Variables are like containers which are used to store the values for some input,
intermediate result of calculations or the final result of a mathematical operation
in computer memory.
2
Review of Python | Vineeta Garg
11. What is the difference between mutable and immutable data types?
12. What are the comments? Declare a single line comment and a multi-
line comment.
Comments are the line that compiler ignores to compile or execute. There are two
types of comments in Python
3
Review of Python | Vineeta Garg
• Single line comment: This type of comment deactivates only that line
where comment is applied. Single line comments are applied with the help of
“ #”. For e.g.
• Multi line Comment: This Type of comment deactivates group of lines when
applied. This type of comments is applied with the help of triple quoted
string.
'''This is a
multiline comment'''
or
"""This is a
multiline comment"""
SYNTAX ERROR: An error in the syntax of writing code that does not conform
to the syntax of the programming language is called a syntax error.
LOGICAL ERROR: It is an error in a program's source code that results in
incorrect or unexpected result. It is a type of runtime error that may simply
produce the wrong output or may cause a program to crash while running.
RUN TIME ERROR: A runtime error is an error that occurs during execution of
the program and causes abnormal termination of program.
4
Review of Python | Vineeta Garg
/ // %
Divides two operands Integer division Divides two operands
and gives quotient and gives remainder
10/5=2 5//2=2 10%5=0
10/3.0 = 3.3 5.0//2=2.0
10.0/3=3.3
10/3=3
* **
Multiplies two operands Exponentiation
10*5=50 2**4= 16
= ==
Assigns the value Checks if the value of left operand is
equal to the value of right operand, if
yes then condition becomes true.
x=50 15= = 15, true
16 = = 15, false
>>> str3=str2+str1
5
Review of Python | Vineeta Garg
>>> print(str3)
EraTech
6
Review of Python | Vineeta Garg
[121, 'KABIR',
'RAMESH', 890, OUTPUT OUTPUT
453.9]
[100, 200, 300, 400, [121, 'KABIR',
500, 'Raman', 100, 'RAMESH', 890,
'Ashwin'] 453.9,10]
24. What is the difference among del, remove or pop methods to delete
elements from a List?
>>> list1 =[100, 200, >>> list1=[100, 200, >>> list1=[100, 200,
90, 'Raman', 100, 'Raman', 100] 50, 400, 500,
'Ashwin'] >>> del list1[2] 'Raman', 100,
>>> print(list1) 'Ashwin']
>>> list1.pop(2)
>>> list1.remove(400)
OUTPUT >>> print(list1)
OUTPUT
90 [100, 200, 100] OUTPUT
7
Review of Python | Vineeta Garg
25. What are the major differences between key and value in a
dictionary?
key value
Keys are unique Values may not be unique
The keys must be of an immutable data The values of a dictionary can be of
any type
type such as strings, numbers, or
tuples.
26. Give the difference between upper() and isupper() functions of string.
The upper() function returns the copy of the string with all the letters in
uppercase. The isupper() function returns True if the string is in uppercase.
Example
>>> print(str3.upper())
ERATECH
8
Review of Python | Vineeta Garg
The else clause in looping statements is executed when the loop terminates.
BREAK CONTINUE
s=10; s=10;
for i in range (10, 20, 3): for i in range (10, 20, 3):
s+=i s+=i
if(i==16): if(i==16):
break continue
print(s); print(s);
print("end"); print("end");
OUTPUT: OUTPUT:
20 20
33 33
end 68
end