Descriptive Questions
Descriptive Questions
5. What is an interpreter?
一 An interpreter is a software which converts a high-level
language program into machine language and gets it executed line
by line.
6. What is IDLE? What are the two modes of working with IDLE?
Ans:
IDLE is the default IDE of Python. It stands for Integrated
Development and Learning Environment. Two modes of working with
IDLE are: Interactive mode and Script mode.
7. What is print() in Python?
print() is a function to display the specified content on
screen.
8. Name the keyword arguments of print() function.
(i) 7 (ii) '7' (iii) "7" (iv) 7.0 (v) '''7''' (vi) -0.7 (vii) -
29 (viii) -15.38
(ix) "29 acres" (x) ". & #"
Ans: (i) int (ii) str (iii) str (iv) float (v) str (vi) float
(vii) int (viii) float (ix) str (x) str
Ans: (i) 122.0 (ii) 11.0 (iii) 14.0 (iv) 49 (v) 4 (vi) 9
15. What is a variable? What are the rules for forming valid
variable names in Python?
A variable is the name given to a data object stored in memory.
Rules for forming valid variable names in Python:
• A variable name must start with an alphabet or an underscore
(_).
• A variable name can consist of UNICODE alphabets, digits, and
underscore(_). No other character is allowed.
• A Python keyword cannot be used as a variable name.
24. Define syntax error, run time error, and logical error. Give
an example of each.
Syntax error: A syntax error is a grammatical error in a
script. Example: mismatching parentheses.
Run time error: A run time error is an error which occurs during
program execution due to incorrect or illegal values used in
some operations. Example: division by zero.
Logical errors: These are the errors in the logic of the script.
Example: incorrect sequence of statements in the script.
26. Observe the following script and enlist all the tokens used
in it. For each token, write its category too:
#Identify tokens in the script
name="Arjun"
age=eval(input("Enter age: "))
print(name,"is",age,"years old")
Token Category Token Category
(i) a>b/2 (ii) a<=b/2 (iii) a!=b (iv) b==a**2 (v) a+b > -b*-a
(vi) b*2 > ord("2")(vii) c==d (viii) c>d (ix) c<d (x) "c"<"d"
(xi) "c"==c (xii) d != chr(ord("d"))
Ans: (i) False (ii) True (iii) True (iv) False (v) False
(vi) False (vii) False (viii) True (ix) False (x) True (xi)
False (xii) True
(OR (num1+num2)%2 != 0)
33. What is the main difference between a for loop and a while
loop?
Ans:
for loop iterates over the elements of an iterable whereas a
while loop iterates while a specified condition is true.
34. When does the else clause of a loop get executed? Is else
clause mandatory in a loop?
Ans:
else clause of a loop gets executed after the normal completion
of the loop. else clause is not mandatory in a loop.
Example
for i in range(1,9):
if i%3==0:
print(i)
else:
print("program over")
Ans:
try:
n=int(input("Enter an integer to find its reciprocal: "))
print("reciprocal=",1/n)
except NameError: print("Variable not found")
NameError will occur in the script when the user enters a
variable name instead of an integer.