(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
Python Assignment 1 Answers (1).docx
1. ASET Amity University, Noida
Python
Assignment-1
2021-2022
5 CSE 9Y
Submitted By: Shivam
Tripathi
(A2305219629)
Guided By: Neetu Mam
2. ANSWERS
A-1 Lists are used to store multiple items in a
single variable. Lists are created using square
brackets: list = ["apple", "banana", "cherry"].
append(): Adds an element at the end of the
list.
clear(): Removes all the elements from the list.
copy(): Returns a copy of the list.
count(): Returns the number of elements with
the specified value.
extend(): Add the elements of a list to the end
of the current list.
index(): Returns the index of the first element
with the specified value.
insert(): Adds an element at the specified
position.
pop(): Removes the element at the specified
position.
reverse(): Reverses the order of the list.
sort(): Sorts the list.
3. A-2:
1. The split() method splits a string into a list.
Ex:
2. A slice object is used to specify how to slice
a sequence. You can specify where to start
the slicing, and where to end.
3. The strip() method removes any leading
(spaces at the beginning) and trailing
(spaces at the end) characters (space is
the default leading character to remove)