Загрузка...

🚀 NPTEL Python for Data Science | Week 2 Assignment Answers + Explanations 🔥 #Shorts

📌 NPTEL Python for Data Science – Week 2 Assignment | Detailed Explanation

In this video, I have explained all Week 2 assignment questions with clear Python concepts. Below are the explanations for each question:

---

🔹 Q1. Which object does not support indexing?
Options: Tuple / List / Dictionary / Set

👉 Explanation:
Lists and tuples support indexing using positions like "[0]", "[1]".
Dictionaries use keys for access.
Sets are unordered collections, so indexing is not supported.

✅ Answer: Set

---

🔹 Q2. NumPy Indexing Output
"arr[0][1]"

👉 Explanation:
"arr[0]" selects the first row → "[1 2 3]"
Then "[1]" selects the element at index 1 → "5"? Actually based on the array given, it returns the second row element shown in the question.

✅ Answer: "[4 5 6]"

---

🔹 Q3. Set and List Output

👉 Explanation:
"len(s)" gives the number of elements in the set.
Loop runs that many times, and values "1+i" are added to the list.
So list becomes "[1, 2, 3, 4]".

✅ Answer: "[1, 2, 3, 4]"

---

🔹 Q4. NumPy Reshape

👉 Explanation:
"np.arange(0,15)" creates numbers from 0 to 14.
"reshape(3,5)" arranges them into 3 rows and 5 columns.

✅ Answer:
"[[0 1 2 3 4]"
" [5 6 7 8 9]"
" [10 11 12 13 14]]"

---

🔹 Q5. String Formatting

👉 Explanation:
"format()" replaces "{}" with the given value.
Both variable-based formatting and direct string formatting work correctly.

✅ Answer: Both correct options

---

🔹 Q6. Tuple Operations

👉 Explanation:
Tuples are immutable, so "append()" is invalid.
Tuple concatenation, indexing, and tuple creation are allowed.

✅ Answer:
"x = t2[t1[1]]"
"t3 = t1 + t2"
"t3 = (t1, t2)"
"t3 = (list(t1), list(t2))"

---

🔹 Q7. Dictionary Operations

👉 Explanation:
Lists inside dictionaries are mutable, so "append()" works.
New key-value pairs can also be added directly.

✅ Answer:
"d[2].append(4)"
"d["one"] = 1"

---

🔹 Q8. Which data type is immutable?

👉 Explanation:
Lists, sets, and dictionaries can be modified.
Tuples cannot be changed after creation.

✅ Answer: Tuple

---

🔹 Q9. Dictionary Update

👉 Explanation:
"update()" modifies existing keys and can add new keys.
Direct assignment also adds a new key.

✅ Answer:
"student.update({'age':26, 'phone':'123-456'})"
"student['phone'] = '123-456'"

---

🔹 Q10. String Capitalize Output

👉 Explanation:
"capitalize()" makes the first letter uppercase.
Each character is processed individually, so every letter becomes uppercase.

✅ Answer: "['M', 'A', 'H', 'E', 'S', 'H']"

---

💬 Comment your week number for the next solution.
👍 Like • Share • Subscribe for more NPTEL Python solutions

#NPTEL #Python #DataScience #PythonForDataScience #NPTELAssignments #Coding #YouTubeShorts

Видео 🚀 NPTEL Python for Data Science | Week 2 Assignment Answers + Explanations 🔥 #Shorts канала Mayank Sahani
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять