0% found this document useful (0 votes)
2 views7 pages

Day Task_ Python Lists

The document outlines a series of Python tasks related to list operations, including creating, modifying, and accessing lists. It covers various methods such as append, insert, remove, and pop, as well as concepts like slicing, indexing, and counting elements. Each task provides specific instructions and expected outputs to guide users in practicing their Python list skills.

Uploaded by

Kelu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Day Task_ Python Lists

The document outlines a series of Python tasks related to list operations, including creating, modifying, and accessing lists. It covers various methods such as append, insert, remove, and pop, as well as concepts like slicing, indexing, and counting elements. Each task provides specific instructions and expected outputs to guide users in practicing their Python list skills.

Uploaded by

Kelu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Day Task: Python Lists

1. Daily Essentials

Create a list of 4 items you use daily and print it.

2. Contacts Peek

Save 3 names and print only the first and last.

3. Last Match Score


scores = [12, 45, 67, 23]

👉 Print the latest score


👉 Output:
23

4. Slice View
data = [10, 20, 30, 40, 50]

👉 Print the middle 3 values.


👉 Output:
[20, 30, 40]

5. Flipkart Sales

A company maintains all their sales in a list.​


Today 400 new sales happened. Add it.

sales = [150, 550, 230]

👉 Output:
[150, 550, 230, 400]

Hint: append()

6. Party Playlist

Your friend sends you 3 songs at [Link] want to add them to your playlist. Add them
properly so they play individually.

playlist = ["song1", "song2"]

👉 Output:
["song1", "song2", "song3", "song4", "song5"]

Hint: NOT append()

7. Trending Movie

You want a movie to appear second on your favourite movies list.

movies = ["A", "C"]


👉 Output:
["A", "B", "C"]

8. Undo Mistake

You pressed a wrong move in a game — remove ONLY the last one.

moves = [5, 8, 2]

👉 Output:
[5, 8]

9. Fake Entry

A fake username named "bot" got added — remove it.

users = ["ram", "bot", "shyam"]

👉 Output:
["ram", "shyam"]

→ If there are more than one entries named bot.. Will all of them get removed? Why or
why not?

10. Count Check

Find how many times "error" occurred.

logs = ["ok", "error", "ok", "error", "error"]

👉 Output:
3
[Link] indexing

data = [10, 20, 30, 40]

Print [10,20] using negative indexing.

12. Ranking Twist


scores = [50, 10, 40]
Sort the scores in ascending order

👉 Output: [10, 40, 50]​


→ Now reverse it to get highest first

13. Smart UI Filter


data = [10, 20, 30, 40, 50]
print(data[1::2])

👉 Output:
[20, 40]

Why not [10, 30, 50]?

14. Memory Confusion


a = [1, 2]
b=a
[Link](3)

print(a)

👉 Output:
[1, 2, 3]

👉 Why did a change?


15. Safe Copy
a = [1, 2]
b = [Link]()
[Link](3)

print(a)

👉 Output:
[1, 2]

What changed here?

[Link] List Usage


1.​ How do you create a list of 3 fruits: "apple", "banana", and "cherry"?
2.​ What is the output of len(["a", "b", "c", "d"])?
3.​ How do you access the first item in the list colors = ["red", "green", "blue"]?
4.​ How do you get the last item from numbers = [10, 20, 30] using a negative index?
5.​ What does colors[1] return from colors = ["red", "green", "blue"]?

[Link] Modification Methods


1.​ Use append() to add "orange" to the list fruits = ["apple", "banana"].
2.​ Use insert() to add "grapes" at index 1 in the list fruits = ["apple",
"banana"].
3.​ Use extend() to add ["kiwi", "mango"] to the end of fruits = ["apple",
"banana"].

[Link] Elements
1.​ Use remove() to delete "banana" from the list ["apple", "banana",
"grapes"].
2.​ Use pop() to remove the last item from the list ["a", "b", "c"]. What is the list
after this?
3.​ What is the output of x = ["a", "b", "c"]; [Link](1)? What will be the new list?
4.​ What happens if you call remove("z") on the list ["x", "y"] and "z" is not in it?

[Link] and Counting


1.​ Use index() to find the position of "python" in the list ["java", "python",
"c++"].
2.​ Use count() to count how many times "apple" appears in ["apple", "banana",
"apple", "cherry"].

[Link] and Reversing


1.​ Sort the list marks = [60, 90, 70] in ascending order using sort().
2.​ Sort the list marks = [60, 90, 70] in descending order using
sort(reverse=True).
3.​ Use reverse() to reverse the list ["a", "b", "c"].
4.​ What is the difference between sort() and reverse()?

[Link] Lists
1.​ Create a copy of a = [1, 2, 3] using the copy() method.
2.​ What is the difference between a = b and a = [Link]()?

[Link] List
1.​ Use clear() to remove all items from a = [1, 2, 3].

[Link] Arithmetic (Concatenation and Repetition)


1.​ What is the result of [1, 2] + [3, 4]?
2.​ What is the result of ["x"] * 3?

[Link] Test
1.​ Use the in keyword to check if "AI" exists in the list ["Python", "ML", "AI"].
2.​ What will "SQL" not in ["Python", "ML", "AI"] return?
[Link] and Slicing
1.​ How do you get the first three elements from a = [10, 20, 30, 40, 50] using
slicing?
2.​ What is the output of a[::2] for a = [0, 1, 2, 3, 4, 5]?

[Link] Lists (Minimal)


1.​ What is the output of a = [[1, 2], [3, 4]]; a[1][0]?
2.​ How do you access 4 in the list [[1, 2], [3, 4]]?

[Link], Max, Sum


1.​ Find the largest number in the list [10, 20, 5].
2.​ Find the smallest number in the list [10, 20, 5].
3.​ Get the total of numbers in the list [1, 2, 3, 4].

You might also like