Sunday 8 November 2020

Class 12th sumita arora solutions || Chapter 1- Python Revision tour - 1 || Type-A

Q 1 = What are tokens in Python ? How many types of tokens are allowed in Python ? Exemplify your answer. Answer =  token are smallest individual unit in a program .

Answer =
Token are smallest individual unit in a program .
Type of tokens
1 keywords : False, True , for , while 
2 identifiers : a , A , lst , dic
3 literal  : “python”,5,9, ‘class11’
4 operator : +,-,/,*,**,%,//
5 punctuators :&,^,?,#,@,!

Q 2 = How are keywords different from identifiers ?  

Answer = 
Keywords have special meaning in python while identifier are define by user .

Q 3 = What are literals in Python ? How many types of literals are allowed in Python ? 

Answer = 

Literals are data item or value in python .
There are five type of literal –
1 = string literal
2 = numeric literal
3= Boolean  literal
4 = special literal
5 = literal collection

Q 4 = Can nongraphic characters be used and processed in Python ? How ? Give examples to support your answer.

Answer = 

Yes , non graphic character can be use in python .
In python we can use by type in side of double quote or single quote .
Example –
print (“\\”)
print (“\n”)

Q 5 = Out of the following, find those identifiers, which cannot be used for naming Variables or Functions in a Python program : 
Price*Qty, class, For, do, 4thCol, totally, Row31, _Amount  ?

Answer = 

price*Qty , class , 4thCol .

Q 6 = How are floating constantsrepresented in Python ? Give examples to support your answer.

Answer = 

price*Qty , class , 4thCol .

Q 7 = How are string-literals represented and implemented in Python ?

Answer = 

String literal represented by enclosed by single or double quotes that from string literal in python .

Example :
a = “string ”
print (a)
>>> ‘string’
Print (“python”)  
>>> ‘python’

Q 8 = What are operators ? What is their function ? Give examples of some unary and binary operators.

Answer =

The operation between tow operands is called operator .
Function of operator
To operate two operand by instruction of user .

Example of unary operator :

+ unary plus , -  unary minus etc. 

Example of binary operator :

+ addition , - subtraction etc.

Q 9 = What is an expression and a statement ?

Answer =
Expression is a legal combination of symbol that represent a value.
Statement is a instruction that does something .

Q 10 = What all components can a Python program contain ?

Answer =  

Component of program are as follow :
1 function
2 expression
3 statement
5 blocks
6 indentation

Q 11 = What are variables ? How are they important for a program ?

Answer = 

Variable is a label that can used in process of program . it can contain numeric values , character , string  is called variable.
Variable play very important role in programming because they enable programmers to write flexible programs . without variable we can not enter the data directly in the program

Q 12 = Describe the concepts of block and body. What is indentation and how is it related to block and body ?

Answer = 

A block or suite is a group of statements which are part of another statement or function. Indentation refers to the placement of text further to the right or the left, to separate it from surrounding text. All statements inside a block or suite are intended at the same level.

Q 13 = What are data types ? How are they important ?

Answer = 

Representation of many types of data in by provided facilities is called data type .
Example = integer, string , list etc.
They are play very important role in programming because without any data of program , program can cause error , so program needed data .

Q 14 = How many integer types are supported by Python ? Name them.


Two type of integer are supported by python
(I)Integer (signed)

Q 15 = What are immutable and mutable types ? List immutable and mutable types of Python.

Answer = 

Immutable type :- 

Those types whose value never change  is known as immutable type.

Example = integer , string , Boolean, tuples , e.c.t

Mutable type: - 

Those type whose value can be change is known as mutable type.

Example = list, dictionary, set

Q 16 = What is the difference between implicit type conversion and explicit type conversion ?

Answer = 

The basic difference between implicit and explicit type conversion  is that implicit is taken care by compiler itself , while explicit is done by the programmer .

Q 17 = An immutable data type is one that cannot change after being created. Give three reasons to use immutable data.

Q 18 = What is entry controlled loop ? Which loop is entry controlled loop in Python ?

Answer = 

Entry controlled loop , the loop which has condition checked at the entrance of the loop , the loop executes only and only if the condition is satisfied is called as entry control loop.

Example = while loop, for loop.


Loop where test condition is checked before entering the loop body , know as entry controlled loop.

Q 19 = Explain the use of the pass statement. Illustrate it with an example.

Answer =

A pass statement is useful in those place where the syntax of language requires the presence of a statement but where the logic of the program does not.

Example = in looping

Example =
for I in range (1,11):
        if I % 2 == 0 :
                print (I)

Q 20 = Q. Below are seven segments of code, each with a part colored . Indicate the data type of each colored part by choosing the correct type of data from the following type.
(a) int (b) float (c) bool (d) str (e) function (f) list of int (g) list of str

if temp < 32 :
Answer = function

L = [ 'Hiya', 'Zoya', Preet' ]

Answer = str

M = [ ]
for i in range (3) :
M. append (i)

Answer = list of int

L = [ 'Hiya', 'Zoya', 'Preet' ]
n = len (L)
if ‘Donald’ in L[1: n] :
print (L) (i2)

Answer = int

if n% 2 == 0 :

Answer = bool

(vi) L = inputline.split()
while L != ( ) :
        print (L)
L = L[1:]

Answer = list of str

L= [ 'Hiya', Zoya', 'Preet' ]
print (L[0] + L[1] )  

Answer = str

Credits to PATH WALA 

No comments:

Post a Comment