Anjeev Singh Academy

Anjeev Singh Academy

Class 12 Computer Science 083 Chapter 1 Python Revision Tour I Sumita Arora Book Exercise Solution

Chapter 1 Python Revision Tour I

Type A: Short Answer Questions / Conceptual Questions

1.    What are tokens in Python? How many types of tokens are allowed in Python? Exemplify your Answer.

Answer: Tokens are the smallest individual unit of a program. It is also known as lexical unit.

There are five types of tokens in python –

  • a) Keyword         b) Identifier             c) Literals      d) Operator              e) Punctuators

Example:

                Name = “Anjeev Singh Academy”

                Like = True

                if Like == True:

                        print(“Thank You, Share and Subscribe”)

                else:

                        print(“Please do Like, Share & Subscribe”)

Keyword  -> if , else , True

Identifier -> Name, Like

Literals     ->  “Anjeev Singh Academy”, True

Operators -> =, ==

Punctuator -> :

2.    How are keywords different from identifiers?

Answer: Keywords are reserve words, having special meaning reserved by the programming language.

The identifier is a user defined words, used for naming of variables, function, class, etc.

A keyword cannot be used as identifier.

3.    What are literals in Python? How many types of literal are allowed in Python?

Answer: Literals are the constant values, which cannot be changed.

There are four types of literal –

  • String Literals – Set of characters written inside the quotes (single or double or tipple quotes). String literals can either be single line or multi-line strings.
  • Numeric Literals – Numbers are called numeric literals. Three types of numeric literals.
    • int    – int is called Singed Integers. Number without decimal point.
    • Decimal form – integer beginning with digit 1-9.  Eg. 1258, 5986
    • Octal form – an integer beginning with 0o (zero followed by o). 0o536
    • Hexadecimal form – an integer beginning with 0x (zero followed by letter X). eg. 0x59A, 0xAC5
  • float – Number with decimal point called floating point literals or real literals floats.
    • Fractional Form – 0.126, 569.3698
    • Scientific Form – 0.12E5, 3.E2, .6E-05
  • Complex – are the form a + bj, where a & b are floats, and j is √-1, which is imaginary number. a is the real part and b is the imaginary part.
  • Boolean Literals – True or False is known as Boolean literals.
  • None – None is a special literal. It is use to indicate absence of value.

4.    Out of the following, find those identifiers, which cannot be used for naming Variables or Functions in a Python program.  [CBSE D 2016]

       Price*Qty, class, For, do, 4thC01, totally, Row31, _Amount

Answer: Invalid Identifiers are –

  1. Price*Qty – Special symbol not allowed,
  2. class – Keyword is not allowed as an identifier,
  3. 4thC01 – Identifier cannot start with a digit.

5.    Find the invalid identifier from the following: [CBSE Sample Paper 2020-21]

(a) MyName    (b) True   (c) 2ndName   (d) My_Name

Answer: (b) True  – Keyword is not allowed

        (c) 2ndName – cannot start with digit.

6.    Identify the valid arithmetic operator in Python from the following:  [CBSE Sample Paper 2020-21]

        (a)  ?               (b)  <       (c)  **              (d) and   

Answer: (c) ** [exponentiation operator]

7.    How are floating constants represented in Python? Give examples to support your Answer.

Answer:  float constants – Number with decimal point called floating point literals or real literals floats. It can be represented in two ways:-

  • Fractional Form – 0.126, 569.3698
  • Scientific Form – 0.12E5, 3.E2, .6E-05

8.    How are string-literals represented and implemented in Python?

Answer: String Literals – Set of characters written inside the quotes (single or double or tipple quotes).

String literals can be represented and implemented

  • Single line  –

“Hello How are You”

  • Multi-line strings  – can be written in two ways- (i) by using backslash and (ii) by using triple quotes

By using backslash –

         “Hello \

         How are \

         You”

By using triple quotes (either single or double quote)

         ‘‘‘Hello

         How are you’’’

“““Hello

         How are you”””

9.    What are operators? What is their function? Give examples of some unary and binary operators.

Answer:  Operators are tokens that perform some action or operation on variable or constant i.e. operands.

The main function of the operator is to perform operations on the operand as per their category.

Unary Operators: Unary +, Unary -, not

Binary Operators: Arithmetic Operator, Relational Operator, Logical Operator, Assignment Operator, Membership Operator, Arithmetic Assignment Operator.     

10. Which of the following are valid operators in Python: [CBSE OD 2019]

        (i)  **  (ii) */   (iii) like   (iv) ||  (v) is   (vii) between  (viii) in

Answer: (i), (v) & (viii)

Sorry! You cannot copy content of this page. Please contact, in case you want this content.

Scroll to Top