IP Notes
IP Notes
Ans. Python has one special type called None. The None type is used to indicate something that has not yet
been created in simple words, or absence of value. It is also used to indicate the end of lists in Python.
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.
SECTION C
Q.10 Define -
Ans. a) Keyword: Keyword is a special word that has a special meaning and purpose. Keywords are reserved
and are few. For example, int, float, for, if, elif, else, etc., are keywords.
b) Identifier is a user-defined name given to a part of a program viz. variable, object, function etc.
Identifiers are not 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 instance, _chk, chess, trial etc. are
identifiers in Python.
c) Variable: 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.
Ans. A function in Python is a named block of statements within a program. For example, the following
program has a function within it, namely greet_msg().
# prog1.py
Def greet_msg():
print(name, greet_msg())
Functions are useful as they can be reused anywhere through their function call statements. So, for the
same functionality, one need not rewrite the code every time it is needed; rather, through functions it can
be used again and again.
1. A variable must start with a letter or underscore followed by any number of digits and/or numbers.
3. No special character (other than underscore) should be included in the variable name.
Ans. A token is the smallest element of a Python script that is meaningful to the interpreter.
1. Identifiers – The name of any variable, constant, function, or module is called an identifier.
Ex.
3. Literals – A fixed numeric or non-numeric value is called a literal. It can be defined as a number,
text, or other data that represents values to be stored in variables.
4. Operators – An operator is a symbol or a word that performs some kind of operation on the given
values and returns the result.
Ex. +, -, *, /, etc.
5. Punctuators/Delimiters – Delimiters are the symbols which can be used as separators values or to
enclose some values.
Ex. ( ) {} [ ] , ; :
return output
Ans. The function header has colon missing at the end. So, we need to add colon(:) at the end of the header
line. Thus, the corrected code will be:
return output
Q.16 Write a Python program to calculate and display the selling price of an item.
# p = profit
sp = cp + p
Enter profit: 12
Selling Price: 62
Q.17 Write a Python program that accepts radius of a circle and prints its area.
pi = 22/7
Area = pi*r**2