Class 11 Computer Science Ch 7 Python Fundamental – Check Point 7.2 Sumita Arora Solution

Ch 7 Python Fundamental – Check Point 7.2

Sumita Arora Book Exercise Solution

1. What are literals? How many types of literal are available in Python?

Answer: Literals means constant, a data item that has a fixed value is called Literals.

There are five types of literals: –

(a) String Literals
(b) Numeric Literals
(c) Boolean Literals
(d) Special Literal None
(e) Literal Collections

2.  How many types of integer literals are allowed in Python? How are they written?

Answer: Integer literals are whole numbers without any fractional part. It can be a positive or negative number.

There are three types of integer literals in Python –

(a) Decimal Integer Literal: 125, 6985, 0 ,  -9839

(b) Octal Integer Literal: Octal integer literal starts with 0o. (Zero and English alphabet o). It can contain only 0 to 7 digits.

(c) Hexadecimal Integer Literal: Start with 0x. (Zero and English alphabet x). It can contain 0 to 9 and A to F.

3. Why are characters \, ’, ” and tab typed using escape sequences?

Answer: When these characters \, ’, ” , \t (tap typed) are typed without escape sequence, then these behave differently because these characters have some special meaning and special purpose.

4. Which escape sequences represent the newline character and backspace character? An escape sequence represents how many characters?

Answer: \n represents a newline character. \b represents the backspace character.

An escape sequence represents 1 character only and it consumes one byte in ASCII representation.

5. What are string literals in Python How many ways, can you create String literals in Python? Are there any differences between them?

Answer:  A string literal is a sequence of characters surrounded by single/double/triple quotes.

There are two types of String literals in python –

(a) Single line Strings / Basic strings – Strings enclosed in single ‘’ or doubles “” are called Single line / basic strings.

‘Anjeev Singh’,       “My WhatsApp Number is 9541847706”

(b) Multiline Strings –  In python, the multiline strings can be written in two ways – (i) by using backslash and (ii) by using triple quotes

By using backslash – A basic string (enclose in the single or double quote) can be written in multiline, but it is considered a single-line string. For example

>>> st = “Anjeev\

Singh”

>>> print(st)

AnjeevSingh

By using triple quote (single triple quote / double quote triple quote) – In python actual multiline string can be written with the help of triple single or double quote.

>>> st = ‘‘‘Anjeev

Singh’’’

>>> print(st)

Anjeev

Singh

Note : st = “Anjeev\nSingh”

6. What is meant by a floating-point literal in Python? How many ways can a floating literal be represented?

Answer: Numbers having decimal points or fractional parts are called floating-point literals. It is also known as real number literals.

Floating point literals can be represented in two ways:-

(a) Fractional Form         and          (b) Exponent Form

Fractional Form – A number with decimal point, either positive or negative called Fractional form. Example: – 5, 5.25, 0.525, 12.3698

Exponent Form – A real literal in having mantissa and exponent, called Exponent form. For example: – 0.58E01, 1.25E-8, 0.25E36

Note: In exponent form, (i) exponent can’t be fractional, 0.25E2.6 (ii) comma not allowed as separator, 25, 369.25E25, (iii) Exponent can be in small alphabet e or capital alphabet E.

7. Write the following real constants into exponent form:

23.197, 7.214, 0.00005, 0.319

Answer: 23.197     =      0.23197e2       or 2.3197e1

7.214       =      0.7214e1         or 7.214E0

0.00005   =      0.5E-4

0.319       =      0.319e0           or 3.19e-1

8. Write the following real constants into fractional form.

0.13E04, 0.417E-04, 0.4E-5, .12E02, 12.E02

0.417E-04       =      0.0000417

0.4E-5             =      0.000004

.12E02             =      12.0

12.e02             =      1200.0

9. What are the two Boolean literals in Python?

Answer: Two Boolean Literals in Python are: True and False.

10. Name some built-in literals of Python.

Answer: True, False, and None are built-in literals of Python.

11. Out of the following literals, determine their type whether integer literal or a floating point literal in fractional or exponent form or string literal or other.

123, ‘abc’, “ABC”, 12.34, 0.3E-01, ‘‘‘ftghjkjl’’’, None, True, False

‘abc’        =      string

“ABC”    =      string

12.34       =      floating literal in fractional form

0.3E-01   =      floating literal in exponent form

None       =      Special literal None

True        =      Boolean Literal

False        =      Boolean Literal

12. What kind of program elements are the following?

‘a’ , 4.38925, “a”, “main” ?

Answer: ‘a’ , 4.38925, “a”, “main”  all are literals.

‘a’, “a”, “main” are string literals

4.38925    is a floating point literal.