Informatics Practices
Consider the following list.
emp=["Aditya", 40000, "Deepak",50000, "Yashmit", 60000, "Bhavya", 80000]
(i) To Insert the value "Ramit" at index number 4.
(ii) To check whether element 50000 is present in the list or not.
(iii) To display the first 3 elements from the list.
(iv) To remove the fifth element from the list.
Python List Manipulation
1 Like
Answer
(i)
emp.insert(4, "Ramit")
(ii)
50000 in emp
(iii)
print(emp[:3])
(iv)
del emp[4]
Answered By
2 Likes
Related Questions
The data type list is an ordered sequence which is mutable and made up of one or more elements. Unlike a string which consists of only characters, a list can have elements of different data types such as integer, float, string, tuple or even another list. A list is very useful to group elements of mixed data types. Elements of a list are enclosed in square brackets and are separated by comma.
(i) How is a list different from a dictionary?
(ii) Find the values of y and z after execution:
x=[2, 3] y=[30, 40] z=[88, 99] y.extend(x) z.append(x) print (y) print (z)Write a program in Python to input elements in an empty list. Also delete an element from the list which a user will input.
An organization wants to create a table EMPLOYEE, DEPENDENT to maintain the following details about its employees and their dependents.
EMPLOYEE (EmployeeID, AadhaarNumber, Name, Address, Department)
DEPENDENT (EmployeeId, DependentName, Relationship).
There are 10 records each in both tables.
(i) Name the attributes of the Employee, which can be used as candidate keys.
(ii) What is the degree of the Employee Table?
(iii) What is the Cardinality of a Dependent Table?
(iv) Which is the Primary key of Dependent Table?
Find out the errors in the following code snippet and rewrite the code by underlining the corrections made.
30=y for i in range (2, 6) print (true) else: print ("Loop over")