[go: up one dir, main page]

0% found this document useful (0 votes)
23 views4 pages

IP Notes

Ggg

Uploaded by

rishi07jaiswal00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

IP Notes

Ggg

Uploaded by

rishi07jaiswal00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

IP-Notes

Q.5 What is None literal in Python?

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.

Q.6 Write any two features of Python library.


Ans. Features of Python library are:
1. Python library is very portable and cross-platform compatible with UNIX. Windows and Macintosh.
2. It is easily compatible with other languages like C, C++, Core Java, etc.
3. Python is used for both scientific and non-scientific programming.
Q.7 Why is Python interpreted?

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.

Q.8 How many types of strings are supported in Python?

Ans. Python allows two string types:

1. Single line Strings – Strings that are terminated in single line

2. Multiline Strings – Strings storing multiple lines of text

Q.9 Write Advantages of Python language.

Ans. Advantages are:

1. Platform-independent 2. Readability 3. Higher Productivity

4. Object-Oriented Language 5. Less Learning Time 6. GUI Programming

SECTION C

Q.10 Define -

a) Keyword b) Identifier c) Variable

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.

Q.11 What is function? How is it useful?

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 (“Hello there!!”)

name = input(“Your name:”)

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.

Q.12 What are variable-naming conventions?

Ans. Variable-naming conventions are:

1. A variable must start with a letter or underscore followed by any number of digits and/or numbers.

2. No reserved word or standard should be used as the variable name.

3. No special character (other than underscore) should be included in the variable name.

4. Case sensitivity should be taken care of.

Q.13 What is Tokens? Explain

Ans. A token is the smallest element of a Python script that is meaningful to the interpreter.

The following categories of tokens exist:

1. Identifiers – The name of any variable, constant, function, or module is called an identifier.

Ex. abc, x12y, india_123, swap, etc.


2. Keyword – The reserved words of Python which have a special fixed meaning for the interpreter
are called Keywords. No keyword can be used as 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.

Ex. 2, -23.6, “abc”, „Independence‟, etc.

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. ( ) {} [ ] , ; :

Q.14 What are the Limitations of Python?

Ans. Limitations of Python are:

1. Speed 2. Mobile Development 3. Memory Consumption

4. Database Access 5. Runtime Errors

Q.15 Find the error.

def minus (total, decrement)

output = total – decrement

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:

def minus (total, decrement):

output = total – decrement

return output

Q.16 Write a Python program to calculate and display the selling price of an item.

Program: # cp = cost price


# sp = selling price

# p = profit

cp = int(input(“Enter cost price: ”))

p = int(input(“Enter profit: ”))

sp = cp + p

print(“Selling Price: “, sp)

Output: Enter cost price: 50

Enter profit: 12

Selling Price: 62

Q.17 Write a Python program that accepts radius of a circle and prints its area.

Program: # r = Radius of a circle

# pi(π) have fixed value i.e. 22/7 or 3.14

r = int(input(“Enter Radius of a Circle in cm: ”))

pi = 22/7

Area = pi*r**2

print(“Area of Circle: “, Area)

Output: Enter Radius of a Circle in cm: 7

Area of Circle: 154

You might also like