Pages

Friday, 9 August 2019

CBSE Class 11 - Informatics Practices - Python Basics Questions and Answers (Part-2) (#eduvictors)(#cbsenotes)

Python Basics  Q & A (Part-2)

CBSE Class 11 - Informatics Practices
CBSE Class 11 - Informatics Practices - Python Basics  Questions and  Answers (Part-2) (#eduvictors)(#cbsenotes)


Q1: What are the different modes that can be used to test Python Program?  

Answer: In Python, programs can be written in two ways namely Interactive mode and Script mode.
Interactive mode or Interpreter mode allows us to write codes in Python command prompt  (  >>> ).
Script mode is used to create and edit python source file with the extension .py


Q2: Write the command to leave python shell or interpreter.

Answer: ^D (Ctrl+D) or quit () is used to leave the interpreter.


Q3: What is the advantage of interpreter mode?

Answer:  Working in interactive mode is convenient for beginners and for testing small pieces of code, as we can test them immediately.




Q4: What are the benefits of using script mode?

Answer: In interactive mode, the drawback is that we cannot save the statements for further use and we have to retype all the statements to re-run them. In a long run, script mode is better since one can save code as python script file, may modify and reuse the code.


Q5: What are tokens in Python?

Answer: Python breaks each logical line into a sequence of elementary lexical components known as Tokens.

The Python, token types are:
Identifiers,
Keywords,
Operators,
Delimiters and
Literals.


Q6: What is variable or object in Python? What does it has?

Answer: Object or variable is a name which refers to a value. When we create a program, we often like to store values so that it can be used later. We use objects to capture data, which then can be manipulated by computer to provide information.

An object has:
- Identity
- A type or data type
- A value


Q7: In expression age = 15, identify the object and its value.

Answer: Object or variable is named as i.e. identifier "age". It is of integer data type and its value is 15.


Q8: Are variable age, Age and AGE are same?

Answer: No, these are three different variables. Python is case sensitive, so age, Age and AGE are different identifiers because one begins with a lowercase letter and the other begins with an uppercase letter.


Q9: What is a data type? Draw hierarchy chart showing different data types in Python.

Answer:  Type (i.e data type) is a set of values, and the allowable operations on those values. It can be one of the following:

CBSE Class 11 - Informatics Practices - Python Basics  Questions and  Answers (Part-2) (#eduvictors)(#cbsenotes)


Q10: List the general rules one should obey while naming and using variables.

Answer:

1. Variable names can contain only letters, numbers, and underscores. They can start with a letter or an underscore, but not with a number. e.g. age_1 is valid but 1_age is not a valid name.

2. Spaces are not allowed in variable names, but underscores can be used to separate words in variable names.

3. Python keywords and function names cannot be used as variable names.

4. Python is case sensitive, so age and Age are two different variables.

5.  Python does not allow punctuation character such as %,$, @ etc., within identifiers.


Q11: Identify valid and invalid identifiers from the following list:
Sum, 12Name, total_marks, name$, total-mark, regno, num1, continue


Answer:
  Valid identifiers: Sum, total_marks, regno, num1
  Invalid identifiers: 12Name, name$, total-mark, continue


Q12: What are keywords?

Answer: Keywords are special words used by Python interpreter to recognize the structure of program.  Keywords have specific meaning for interpreter, they cannot be used for any other purpose. e.g. false, class, If, elif, else, pass, break etc.


☛See also:

No comments:

Post a Comment

We love to hear your thoughts about this post!

Note: only a member of this blog may post a comment.