1708872170907

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Colonel’s Brightland Public School,Agra

Class: XI Subject: Computer Science


Chapter: Fundamental of Python Topic: Questions
Assignment No. : 3 Prepared by: Nagendra Singh
1 What is None literal in Python?
Ans: Python has one special literal, which is None. The None literal is used to indicate
absence of value. It is also used to indicate the end of lists in Python. It means ―There
is nothing here‖ .
2 What is the error in following code: x, y =7 ?
Ans: The following error comes - 'int' object is not iterable. Which means an integer
object i.e. cannot be repeated for x and y. one more integer object is required after
7.
3 what will the following code do: a=b=18
Ans: This code will assign 18 to a and b both.
4. Following code is creating problem X = 0281, find
reason. Ans: 0281 is an invalid token.
5 Find the error in the following code:
(a) temp=90 (b) a=12 (c) print(“x=”x)
Print temp b=a+b

print( a And b)

(d) a, b, c=2, 8, 4 (e) x = 23 (f) else = 21-4


print(a, b, c) 4=x

c, b, a = a, b, c

print(a; b; c)

Ans: (a) Missing parentheses in call to 'print'.


(b) Name ‗b‘ is not defined.
(c) Invalid Syntax.
(d) Invalid Syntax in second print statement.
(e) can't assign to literal in second line.
(f) Invalid Syntax.

6 Find the error in the following code:


(a) y = x +5 (b) a=input(“Value: “) (c) print(x = y
= 5) print(x,y) b = a/2
print( a, b)

Ans: (a) Name 'x' is not defined.


(b) Unsupported operand type(s) for /: 'str' and 'int'.
(c) Invalid Syntax.
7 What is the difference between a keyword and an identifier?
Ans: Difference between Keyword and Identifier: Every language has keywords and
identifiers, which are only understood by its compiler. Keywords are predefined reserved
words, which possess special meaning. An identifier is a unique name given to a particular
variable, function or label of class in the program.
8 What are literals in Python? How many types of Literals allowed in Python?
Ans: Literals: Python comes with some built-in objects. Some are used so often that Python
has a quick way to make these objects, called literals.
The literals include the string, Unicode string, integer, float, long, list, tuple and
dictionary types.
9 How many types of sequences are supported in Python?
Ans: Three Types of Sequences are supported in python:
(i) String
(ii) List
(iii) Tuple
10 What factors guide the choice of identifiers in program?
Ans: (i) An identifier must start with a letter or underscore followed by any number of
digits and/or letters.
(ii) No reserved word or standard identifier should be used.
(iii) No special character (Other than underscore) should be included in the identifier.
11 What is the difference between an expression and a statement in Python?
Ans: A statement is an instruction that the Python interpreter can execute. We have only seen the
assignment statement so far. Some other kinds of statements that we‘ll see shortly
are while statements, forstatements, if statements, and import statements. (There are
other kinds too!)
An expression is a combination of values, variables, operators, and calls to functions.
Expressions need to be evaluated. If you ask Python to print an expression, the
interpreter evaluates the expression and displays the result.
12 What are tokens in Python? How many types of tokens allowed in
Python? Ans: Tokens are the smallest unit of the program. There are following
tokens in Python:
 Reserved words or Keywords
 Identifiers
 Literals Definition of all tokens may come. Which is not given
 Operators in this question bank.
 Punctuators

You might also like