MBOSE Class XI Computer Science · Chapter 5
Getting Started with Python
Opening soonYour first Python programs: names, values, data types, operators, input and output, type conversion and the three kinds of errors.
15 lessons · 67 practice questions
What this chapter covers
- Introduction to Python, features, executing a "hello world" program, interactive and script mode
- Python character set
- Tokens (keyword, identifier, literal, operator, punctuator)
- Variables, l-value and r-value, comments
- Data types (number: integer, floating point, complex; boolean; sequence: string, list, tuple; None; mapping: dictionary)
- Mutable and immutable types
- Operators (arithmetic, relational, logical, assignment, augmented assignment, identity, membership)
- Precedence
- Expressions, statements, type conversion (implicit and explicit), input and output
- Errors (syntax, logical, run-time)
Key terms
- Interpreter
Executes Python code line by line
- Token
Smallest unit of a program (keyword, identifier, literal, operator, punctuator)
- Keyword
Reserved word such as
iforwhile- Identifier
Name of a variable, function etc.
- Variable
Name that refers to a value in memory
- l-value / r-value
Place that receives a value / value that is stored
- Literal
A fixed value written in the code (10, 'a', True)
- Mutable / immutable
Can / cannot be changed after creation
- Operand, operator
Value acted on / symbol that acts
- Implicit / explicit conversion
Done by Python / done by
int(),float()etc.- Syntax, logical, run-time error
Grammar mistake / wrong answer / failure while running
Important questions with answers
10 of the 67 questions on this chapter, solved.
Question 1 · Multiple choice · 1 mark
Python is a(n)
- (a) compiled language
- (b) assembly language
- (c) machine language
- (d) interpreted language
Answer: (d) interpreted language
An interpreter runs Python statements one by one.
Question 2 · Multiple choice · 1 mark
What is the type of 5.0?
- (a) int
- (b) float
- (c) str
- (d) complex
Answer: (b) float
A number with a decimal point is a float.
Question 3 · Multiple choice · 1 mark
What is printed by print(5 > 3 > 1)?
- (a) True
- (b) False
- (c) error
- (d) None
Answer: (a) True
It means 5 > 3 and 3 > 1.
Question 4 · Multiple choice · 1 mark
What is printed by print("ab" * 3)?
- (a) ababab
- (b) ab3
- (c) error
- (d) abab
Answer: (a) ababab
*repeats a string.Question 5 · Assertion and reason · 1 mark
Assertion (A): Python is case sensitive.
Reason (R):
Nameandnameare different identifiers.- (a) Both A and R are true, and R is the correct explanation of A.
- (b) Both A and R are true, but R is not the correct explanation of A.
- (c) A is true, but R is false.
- (d) A is false, but R is true.
Answer: (a) Both A and R are true, and R is the correct explanation of A.
R explains A.
Question 6 · Short answer · 1 mark
Name the function used to display output in Python.
Answer
print().Question 7 · Short answer · 2 marks
What is an identifier? State two rules for naming it.
Answer
A name for a variable, function etc. It must start with a letter or underscore and cannot be a keyword (also no spaces or special symbols).
Question 8 · Short answer · 3 marks
Explain syntax error, logical error and run-time error with an example of each.
Answer
Syntax:
print("Hi"(missing bracket). Logical:avg = a + b / 2for the average. Run-time:10 / 0(ZeroDivisionError). (1 each)Question 9 · Long answer · 5 marks
Explain the features of Python and the two modes of working.
Answer
Section 1.1.
Question 10 · Long answer · 5 marks
Explain all the operators of Python with examples and the order of precedence.
Answer
Section 1.4.
Study the whole chapter
15 step-by-step lessons, all 67 practice questions with hints, flashcards and mock tests for MBOSE Class XI Computer Science.