Computer Science - Informatics Practices Class XI/XII Python List Solved Test Part 4

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test  Part 4

Q1. What do you mean by traversing a list?

Q2. Write a program to print all the elements of given list using for loop.

A = [‘a’,’b’,’c’,’d’,’e’]

Q3. List in python are mutable.(T/F)

Q4. Write the output of the following:

             

Q5. Write the output of the following:

S.No.

Code

Output

1

[1,2,3,4] == [4,3,2,1]

 

2

[1,2,3,4] >  [4]

 

3

[1,2,3,4] != [1,2,3,4]

 

4

[1,2,3,4] == [1,2,[3,4]]

 

5

[1,2,3] == [1.0,2.0,3.0]

 

6

 

7

 

8

 

9

 

10

 

11

 

12

 

13

 

14

 

15

>>>   a

>>>   len(a)

 

 

 

Q6. What do you mean by concatenation in list? Explain

    with example.

Q7. Which mathematical operator is used to concatenate

    the list?

Q8. Which mathematical operator is used to replicate

    the list?

Q9. Write the output of the following:

>>> a= “python”

>>> b=list(a)

>>> b*2

>>> b+b

>>> a+a

Q10. Can we multiply two list?

 

 

 

 

 

 

Solutions:

Ans 1: Traversing means to access each element of list

Ans 2.

        

Ans 3. True

Ans 4.

[1,2,3,4]

[1,2,3,4]

[a,2,3,4]

[a,2,3,4]

Ans 5.

S.No.

Code

Output

1

[1,2,3,4] == [4,3,2,1]

False

2

[1,2,3,4] >  [4]

False

3

[1,2,3,4] != [1,2,3,4]

False

4

[1,2,3,4] == [1,2,[3,4]]

False

5

[1,2,3] == [1.0,2.0,3.0]

True

6

[1,2,3,4,5,6,7,8]

7

[1,2,3,4]

8

[1,2,3,4]

9

([1,2,3,4],[5,6,7,8])

10

Error

11

[1,2,3,4,5,6,7,8]

12

Error

13

[1,2,3,4,5]

14

[1,2,3,4,1,2,3,4]

15

>>>   a

>>>   len(a)

 

[1,2,3,4,1,2,3,4]

[1,2,3,4]

4

 

Ans 6. Concatenation of list means combining the two

       list. For example :

>>>a = [1,2,3,4]

>>>b = [5,6,7,8]

>>> a+b

Ans 7. ‘+’ operator

Ans 8. ‘*’ operator

Ans 9. ['p', 'y', 't', 'h', 'o', 'n', 'p', 'y', 't', 'h', 'o', 'n']

          ['p', 'y', 't', 'h', 'o', 'n', 'p', 'y', 't', 'h', 'o', 'n']

       'pythonpython'

Ans 10. NO

Computer Science - Informatics Practices Class XI/XII Python List Solved Test Part 3

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test  Part 3

 Q1. Write the output of the following

      

Q2. Fill the index value in place of ‘?’ as output should come as below:

             

                 

                                

Q3. Write the output of the following three parts:

           

     

                

               

    

SOLUTIONS

Ans1.

1

2

3

4

5

Ans 2

0

1

6

2

1

Ans 3 a)

p

r

a

c

t

i

c

e

Ans 3 b)

practice

Ans 3 c)

p?r?a?c?t?i?c?e?

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test Part 2

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test  Part 2

Q1. Write the code to create the list of::

  1. Five vegetables
  2. Vowels
  3. First 10 natural numbers
  4. Square of first 5 natural numbers.
  5. Any five names of your friends
  6. All the alphabets of word “Taj Mahal”
  7. First five multiples of 6.

Q2. Write a code to convert the string “Practice” into list.

Q3. Write the output of the following:

>>> d = “a*hj?”

>>> list(d)

Q4. Write the output of the following:

>>>a = “String”

>>>list (a)

Q5. Write the output of the following:

>>> a = list ()

>>> a

Q6. What is list() function?

Q7. Write the output of the following:

     

SOLUTIONS

Ans 1:

 b = ['a','e','o','i',u']

 c = [1,2,3,4,5,6,7,8,9,10]

 d = [1,4,9,16,25]

 e = ['amit','anuj','ashu','suman','mridul']

 f = ['T','a','j','M','a','h','a','l']

 g = [6,12,18,24,30,36]


Ans 2: a = list("Practice")

Ans 3: ['a','*','h','j','?']

Ans 4: ['S','t','r','i','n',g']

Ans 5: []

Ans 6: list() function is used to create empty list and it can also convert certain type of object into list.

Ans 7: 

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