Unit4- Introduction to Python
Unit4- Introduction to Python
Artificial Intelligence
CLASS – 9
Chapter 4- Introduction to Python
Sample Questions (with Solution)
I. Multiple Choice Question:
12. In the Python language, which of the following statements is correct for variable names?
a. All variable names must begin with number.
b. Unlimited length
c. The variable name length is a maximum of 2 characters.
d. All of the above
13. A computer ___________ is a collection of instructions that perform a specific task when executed by
a computer.
a. Program
b. Code
c. Code Body
d. None of the above
16. Python is a _________ programming language, which means it runs on a variety of platforms
including Windows, MacOS, Linux, and the Java and.NET Virtual machines.
a. Cross-platform
b. Single-platform
c. Code-platform
d. None of the above
17. Python ___________ must be installed on our machine in order to run a Python program.
a. Interpreter
b. Compiler
c. Assembler
d. All of the above
21. What are the two methods for using a Python shell?
a. Interaction Mode, Sub Mode
b. Interactive Mode, Script Mode
c. Shell Mode, Python Mode
d. None of the above
24. Instructions written in the source code for execution are called ___________.
a. Statements
b. Sentence
c. Both a) and b)
d. None of the above
25. Statements in Python can be extended to one or more lines using _____________.
a. braces{}
b. Parentheses()
c. Square Brackets[]
d. All of the above
26. A _________ is a piece of text that doesn’t impact the outcome of a programme; it’s just a way to tell
someone what you’ve done in a programme or what’s going on in a block of code.
a. Statement
b. Comments
c. Nodes
d. None of the above
27. _________ are the reserved words in Python used by the Python interpreter to recognize the
structure of the program.
a. Keywords
b. Identifiers
c. Comments
d. None of the above
28. An ____________ is a name given to entities like class, functions, variables, etc.
a. Keywords
b. Identifiers
c. Comments
d. None of the above
39. Numbers with fractions or decimal points are called ________ datatype.
a. Integer
b. String
c. Float
d. None of the above
Class 9- Artificial Intelligence
Ch4- Introduction to Python
Sample Question Bank
6
41. What are the different types of Sequence data types in python?
a. String
b. Lists
c. Tuples
d. All of the above
42. String is an ordered sequence of letters/characters. They are enclosed in single quotes (‘ ‘) or double
(“ “).
a. String
b. Integer
c. Float
d. None of the above
43. ___________ are a sequence of values of any type, and are indexed by integers. They are immutable.
Tuples are enclosed in ().
a. String
b. Lists
c. Tuples
d. All of the above
44. __________is an unordered collection of values, of any type, with no duplicate entry.
a. String
b. Set
c. Dictionaries
d. None of the above
45. ____________is an unordered collection of key-value pairs. It is generally used when we have a
huge amount of data.
a. String
b. Set
c. Dictionaries
d. None of the above
46. _________ are special symbols which represent computation. They are applied on operand(s), which
can be values or variables.
a. Operators
b. Operand
c. Declaration
d. None of the above
b. Relational
c. Logical and Assignment
d. All of the above
49. _________ function is used to take input from the user in python.
a. Input()
b. Insert()
c. Store()
d. None of the above
51. Python automatically converts one data type to another datatype. This process is known as
___________.
a. Implicity Type Conversion
b. Explicity Type Conversion
c. Py Type Conversion
d. Both a) and b)
52. Convert the data type of an object to required data type. We use the predefined functions like int(),
float(), str(), etc to perform ____________.
a. Implicity Type Conversion
b. Explicity Type Conversion
c. Py Type Conversion
d. Both a) and b)
3. Python includes a large library of built-in functions that can be used to tackle a wide range of problems.
4. Python features an interactive mode that enables interactive testing and debugging of code snippets.
5. Python runs on a wide range of operating systems and hardware platforms, with the same user interface
across all of them.
6. We can use the Python interpreter to add low-level models. These models allow programmers to make their
tools more efficient by customizing them.
7. Python includes interfaces to all major open source and commercial databases, as well as a more structured
and robust framework and support for big systems than shell scripting.
9. What is Variable?
Answer – In a computer language, a variable is a memory area where a value is stored. A variable in Python is
created when a value is assigned to it. In Python, declaring a variable does not necessitate any additional
commands.
10. What are the different rules for declaring the Variable?
Answer – The rules for declaring variable are –
1. A number cannot be used as the first character in the variable name. Only a character or an underscore can
be used as the first character.
2. Python variables are case sensitive.
3. Only alpha-numeric characters and underscores are allowed.
4. There are no special
1. Numbers
2. Sequences
3. Sets
4. Maps