Class XI : Chapter 1 Python Fundamental Test - 5

 Q1. Write the output of the following :

>>> x = 8

>>> x = 5

>>> print (x + x)

Q2. Is the following statement correct?

>>> a, b, c = 2 , 3 , 'Amit'

Q3. Identify the invalid variable names from the following and specify the reason also.

  1. m_n
  2. unit_day
  3. 24Apple
  4. #sum
  5. for
  6. s name

Q4. What are keywords?

Q5. Keywords can be used as variable names (T/F)

Q6. Write the code to display all the keywords available in python.

Q7. What do you mean by expression?

Q8. Write the python expressions equivalent to the following algebraic/arithmetic expressions

  1. z = u/5
  2. z = 9ab + d
  3. z = x+4/j + 7
 
Q9. What are operators? Name three types of operators.

Q10. >>> 7 % 10 will return ____________________


SOLUTIONS

 Q1. Write the output of the following :

>>> x = 8

>>> x = 5

>>> print (x + x)

Ans. 10

Q2. Is the following statement correct?

>>> a, b, c = 2 , 3 , 'Amit'

Ans. yes

Q3. Identify the invalid variable names from the following and specify the reason also.

  1. m_n
  2. unit_day
  3. 24Apple
  4. #sum
  5. for
  6. s name
Ans. 24apple : Variable can not start with number
        #sum : Variables can not start from special character.
        for : Keyword can not be used as variable
        s name : Spaces are not allowed in variable names

Q4. What are keywords?

Ans. Keywords are reserved words which have special meanings to python

Q5. Keywords can be used as variable names (T/F)

Ans. False

Q6. Write the code to display all the keywords available in python.

Ans. 

import keyword

print(keyword.kwlist)

Q7. What do you mean by expression?

Ans. A combination of operators and operands is called expression. 

        like - a + b * c

Q8. Write the python expressions equivalent to the following algebraic/arithmetic expressions

  1. z = u/5
  2. z = 9ab + d
  3. z = x+4/j + 7
Ans. 
1. z = u/5
2. z = 9*a*b + d
3. z = x + 4/j + 7
 
Q9. What are operators? Name three types of operators.
Ans. Operators are special symbols that perform a specific task (arithmetic 
        or logical operations)
Three types of operators are
1. Logical Operators
2. Relational Operator
3. Mathematical Operator

Q10. >>> 7 % 10 will return ____________________

Ans 7




No comments:

Post a Comment

Most Recently Published

File Handling Test 6

 File Handling Test 6 Q1 . Do we need to use the close() function when we use 'with' statement to open a file? Q2. Which mode you wi...

CS - IP Assignment/Worksheet