Page 332 - Artificial Intellegence_v2.0_Class_9
P. 332
Output will be: ["Chennai", "Delhi", "Kolkata", "Mumbai"] Exercise
city.sort(reverse=True)#sorts the list descending order
Output will be: ["Mumbai", "Kolkata", "Delhi", "Chennai"]
• index(): It returns the index number of the value given in the function. For example, Solved Questions
city=["Delhi", "Mumbai", "Kolkata", "Chennai"]
SECTION A (Objective Type Questions)
city.index("Kolkata") uiz
Output will be: 2
city.index("Pune") A. Tick ( ) the correct option.
Output will be: ValueError 1. Which of the following symbols is used in flowcharts to take an input from the user?
It returns ValueError exception if the value is not found in the list. a. Diamond b. Rectangle
• count(): This function counts the number of occurrences of the specified value in the given list. If the value c. Oval d. Parallelogram
doesn't exist, then the function returns 0. For example,
2. Coding and implementation is the ………………………. step in problem solving.
marks = [56, 67, 45, 78, 56, 78, 12] a. First b. Last
marks.count(78) c. Third d. Second
Output will be: 2
3. Which of the following symbols is used to display the decision-making statements in a flowchart?
marks.count(10)
Output will be: 0 # 10 does not exist in the list. a. Rectangle b. Line
c. Diamond d. Oval
4. Which of the following is the step-by-step approach in simple English-like statements?
At a Glance a. Algorithm b. Selection
• A program is written in any programming language which the computer can understand and execute. c. Flowchart d. Sequence
• Control structures are a set of instructions that controls the flow of instructions in a program. 5. Which of the following is/are powerful tools for learning programming?
• An algorithm is a step-by-step approach to identify and solve a problem in a finite time. a. Flowchart b. Algorithm
• A flowchart is a graphical representation of an algorithm. c. Both a and b d. None of these
• Python is a general-purpose, object oriented, easy to learn and high-level programming language.
6. Which of the following is the valid name for (an) identifier(s) in Python?
• Instructions written in a source code that are executed by a Python interpreter are called statements.
a. Test#4 b. Rollno
• Tokens are the smallest meaningful unit of a program.
• Identifiers are the user defined names of variables, list, dictionary, tuples, classes etc. c. 9thClass d. else
• Variable is a name given to a memory location to hold a specific value. 7. Which of the following is a valid logical operator?
• List is a collection of heterogeneous data arranged in a sequence. a. and b. !=
• The elements of a list can be accessed by using its index number starts with 0 (zero). c. + d. >=
• The + operator is used to concatenate the list with another list.
8. ZeroDivisionError error is a ………………………. .
• The * operator is used to replicate a list specific number of times.
a. Syntax Error b. Logical Error
• The comparison of the lists is done using comparison operators >, <, >=, <=, != and ==. c. Runtime Error d. Not an Error
• The append( ) Function appends a single element with the given value(any datatype) at the end of the list.
• The extend() Function is used to append multiple values at a time in a list. 9. Which of the following is a sequence of UNICODE characters?
• The insert( ) function is used to add a single value at a specific position in an existing list. a. Boolean b. Numbers
• The remove( ) function removes the first occurrence of the element with the specified value. c. String d. Float
• The pop( ) function removes an element from the list based on the index number specified in the function and returns 10. Which of the following is a data type that has two built-in values True or False?
the deleted value. a. String b. Boolean
c. Integer d. Float
330 Touchpad Artificial Intelligence (Ver. 2.0)-IX

