(B) Explain of List Following Operations

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Module-2

(a) What is Dictionary in Python? How is it different from List data type? Explain how (6. Marks)
forloop can be used to traverse the keysinofthe Dictionary
for the
with anexample with
(b)Explain code
the methods of List data type Python following operations
Q.3 suitable snippets for each.
ii) values from list (8 Marks
values to list
(i) Adding a Removing a

ii) Finding a value in a list iv) Sorting the values in a list_


Write a Pyhon progran that accepts a sentence and find the number of words, digits,
(C) uppercase letters and lowercase letters.
(6 Marks)
OR
(a) What is the difference between copy.copy() and copy.deepeopy() funcions
applicableto a Listor Dictionary in Python'? Give suitable examples for each. (6 Marks)
Discuss the following Dictionary methods in Python with examples.
9.4 ) get() i) items(0 (ii) keys(0 (iv) values() (8 Marks)
eExplain the various string methods for the following operations with examples.
both sides
G)Removing whitespace characters from the beginning, end or
of astring. (6 Marks)
i) Toright-justify, left-justify,and center a string.
Module
(a) What is list?Explain the concept of list slicing with example.
(b) Explain references with example.
.3
What is dictionary?How it is different from list?Write a program tocount the number
o f occurances of character in a string.
OR
(a) You are creating a fantasy video game. The data structure to model the player's
inventory will be a dictionary where the keys are string values describing the item in
the inventory and the value is an integer value detailing how many of that item the
player has. For example, the dietionary value {rope': 1, 'torch': 6, 'gold coin': 42,
'dagger': 1, 'arrow': 12) means the player has I rope, 6 torches, 42 gold coins, and so
on.Write a function named displaylnventory) that would take any possible
"inventory" and display it like the following:

Inventory:
12 arrow
42 gold coin
I rope
6 torch
I dagger
Total number of items: 63
List any six methods associated with string and explain each of them with example.
(b)
Module -2
(a) What is list? Explain the concept ofslicing and indexing with proper examples.
For a given list num=[45,22,14,65,97,72], write a python program to replace all the
(b)
Q.3 integers divisible by 3 with "pPP" and all integers divisible by 5 with "qgg" and
replace all the integers divisible by both 3and 5 with "pppggg" and display the output.
What are the different methods supports in python List. Ilustrate all the methods with an

(C)example.
OR
(a)What is dictionary? 1llustrate with an example python program the usage of nested
dictionary.
List
(6) out allfortheeach
useful string
method.
methods which
supports in python. Explainwith an
Q.4 example
What are the different steps in project Adding Bullets to Wiki Markup.
(c)
Module -3
Q.5 (a) What are
regular expression? What are the different steps to be follow to use a regular
Texpression in python._

You might also like