├── .vscode └── settings.json ├── Certificate ├── index.html ├── script.js └── style.css ├── LICENSE ├── README.md ├── images ├── Algo.png ├── arrow.png ├── code.png ├── cross.png ├── dgm-1.png ├── dgm-2.png ├── dgm-3.png ├── dsa-logo.png └── menu.png ├── index.html ├── lesson-03 ├── index.html ├── quiz.css ├── quiz.html ├── quiz.js ├── script.js └── style.css ├── lesson-04 ├── index.html ├── script.js └── style.css ├── lesson-2 ├── index.html ├── quiz.css ├── quiz.html ├── quiz.js ├── script.js └── style.css ├── script.js └── style.css /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[python]": { 3 | "editor.defaultFormatter": "ms-python.autopep8" 4 | }, 5 | "python.formatting.provider": "none" 6 | } -------------------------------------------------------------------------------- /Certificate/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Beautiful Certificate 7 | 8 | 9 | 10 |
11 |
12 |

Certificate of Achievement

13 |
14 |
15 |

This certificate is awarded to:

16 |

[Recipient's Name]

17 |

For outstanding performance and dedication in the field of...

18 |

Date: July 23, 2023

19 |
20 |
21 |

Signature

22 |
23 |
24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Certificate/script.js: -------------------------------------------------------------------------------- 1 | // Function to update the recipient's name dynamically 2 | function updateRecipientName() { 3 | const recipientNameElement = document.getElementById('recipientName'); 4 | const recipientNameInput = prompt('Enter the recipient\'s name:'); 5 | if (recipientNameInput) { 6 | recipientNameElement.textContent = recipientNameInput; 7 | } 8 | } 9 | 10 | // Function to generate and download the certificate as a PDF 11 | function downloadCertificate() { 12 | const certificate = document.querySelector('.certificate'); 13 | const opt = { 14 | margin: 0, 15 | filename: 'certificate.pdf', 16 | image: { type: 'jpeg', quality: 0.98 }, 17 | html2canvas: { scale: 2 }, 18 | jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } 19 | }; 20 | 21 | html2pdf().from(certificate).set(opt).outputPdf().then((pdf) => { 22 | pdf.save(); 23 | }); 24 | } 25 | 26 | // Event listener to update recipient's name 27 | document.getElementById('generateCertificate').addEventListener('click', updateRecipientName); 28 | 29 | // Event listener to generate and download the certificate as PDF 30 | document.getElementById('generateCertificate').addEventListener('click', downloadCertificate); 31 | -------------------------------------------------------------------------------- /Certificate/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | margin: 0; 4 | padding: 0; 5 | display: flex; 6 | justify-content: center; 7 | align-items: center; 8 | height: 100vh; 9 | background-color: #f0f0f0; 10 | } 11 | 12 | .certificate { 13 | width: 80%; 14 | max-width: 600px; 15 | background-color: #f9f6f6; 16 | background-image: linear-gradient(147deg, #ff8a00 0%, #e52e71 100%); 17 | color: #fff; 18 | border: 2px solid #fff; 19 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 20 | padding: 20px; 21 | } 22 | 23 | .header { 24 | text-align: center; 25 | margin-bottom: 20px; 26 | } 27 | 28 | .header h1 { 29 | font-size: 24px; 30 | margin: 0; 31 | padding: 5px 0; 32 | color: #fff; 33 | border-bottom: 2px solid #fff; 34 | } 35 | 36 | .content { 37 | text-align: center; 38 | } 39 | 40 | .content p { 41 | font-size: 16px; 42 | color: #fff; 43 | } 44 | 45 | .content h2 { 46 | font-size: 28px; 47 | color: #fff; 48 | margin-top: 10px; 49 | margin-bottom: 20px; 50 | } 51 | 52 | .signature { 53 | text-align: center; 54 | margin-top: 30px; 55 | } 56 | 57 | .signature p { 58 | font-size: 18px; 59 | font-style: italic; 60 | color: #fff; 61 | } 62 | 63 | button { 64 | display: block; 65 | margin: 20px auto; 66 | padding: 10px 20px; 67 | font-size: 16px; 68 | border: none; 69 | background-color: #fff; 70 | color: #555; 71 | cursor: pointer; 72 | border-radius: 5px; 73 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); 74 | transition: background-color 0.3s ease; 75 | } 76 | 77 | button:hover { 78 | background-color: #ddd; 79 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Pabitra Banerjee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learn-DSA-Using-Python 2 | # Code Explorer - DSA Full Course Using Python 3 | 4 | Welcome to the Code Explorer YouTube playlist! Here, you will embark on a journey to learn Data Structures and Algorithms using the Python programming language. This educational resource is designed to provide you with a comprehensive understanding of essential data structures and algorithms, empowering you to write efficient and elegant Python code for solving real-world problems. 5 | 6 | ## Table of Contents 7 | 8 | - [Introduction](#introduction) 9 | - [Getting Started](#getting-started) 10 | - [Course Structure](#course-structure) 11 | - [Contributing](#contributing) 12 | - [Feedback](#feedback) 13 | - [Contact](#contact) 14 | 15 | ## Introduction 16 | 17 | Data Structures and Algorithms are the backbone of computer science and software development. They are fundamental tools that every aspiring programmer and developer must grasp to write optimized and scalable code. With the Code Explorer YouTube playlist, we aim to demystify these concepts and make them accessible to everyone, regardless of their programming experience. 18 | 19 | ## Getting Started 20 | 21 | To get started with the course, head over to our [YouTube channel](https://www.youtube.com/@Explore-Code) and you can see the playlist named ["DSA Full Course Using Python"](https://www.youtube.com/watch?v=RQKJB7z-OqU&list=PLGxMeslbGNsU38f0599lOC-cRmrf01lD3&pp=iAQB) Make sure to subscribe to our channel and turn on the notification bell to stay updated with the latest content. 22 | 23 | ## Course Structure 24 | 25 | The course is structured in a logical and progressive manner, starting from the basics of Python and gradually diving into various data structures and algorithms. Each video in the playlist will cover a specific topic, providing clear explanations, visualizations, and coding examples to solidify your understanding. 26 | 27 | ### Topics Covered 28 | 29 | 1. Introduction to Python 30 | 2. Arrays and Lists 31 | 3. Linked Lists 32 | 4. Stacks and Queues 33 | 5. Trees and Binary Trees 34 | 6. Graphs 35 | 7. Hash Tables 36 | 8. Sorting Algorithms 37 | 9. Searching Algorithms 38 | 10. Dynamic Programming 39 | ...and more! 40 | 41 | ## Contributing 42 | 43 | We encourage you to contribute to this educational initiative. If you have any suggestions, bug fixes, or additional topics you'd like to see covered, feel free to open an issue or submit a pull request. Together, we can enhance the learning experience for everyone. 44 | 45 | ## Feedback 46 | 47 | Your feedback is invaluable to us! We would love to hear your thoughts on the content, teaching style, and anything else related to the course. Please leave your feedback as comments on the YouTube videos or reach out to us through the contact information provided below. 48 | 49 | ## Contact 50 | 51 | For any inquiries, collaborations, or questions, you can get in touch with us via: 52 | - Email: code.hub.mb.ng.org@gmail.com 53 | - Website: [Code Explorer](https://explorecode.newsgoogle.org) 54 | 55 | Let's embark on this exciting learning journey together! Happy coding! 🚀 56 | -------------------------------------------------------------------------------- /images/Algo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/Algo.png -------------------------------------------------------------------------------- /images/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/arrow.png -------------------------------------------------------------------------------- /images/code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/code.png -------------------------------------------------------------------------------- /images/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/cross.png -------------------------------------------------------------------------------- /images/dgm-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/dgm-1.png -------------------------------------------------------------------------------- /images/dgm-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/dgm-2.png -------------------------------------------------------------------------------- /images/dgm-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/dgm-3.png -------------------------------------------------------------------------------- /images/dsa-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/dsa-logo.png -------------------------------------------------------------------------------- /images/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PB2204/Learn-DSA-Using-Python/f9416c00f7533a8da319102d0a43a13c5acedc66/images/menu.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Learn DSA Using Python || Code Explorer 10 | 11 | 12 | 13 | Learn DSA Using Python || Lesson 01 - Introduction || Code 14 | Explorer 15 |
16 |
17 | 24 |
25 |
26 | Contents 27 | 28 | 142 |
143 |
144 |
145 |

146 | Welcome To DSA Complete Course Using Python By Code Explorer 147 |

148 |
149 |

This Is Introduction To DSA Using Python

150 |
151 |
152 | 156 |
157 |
158 | Full 159 | PlayList 160 |
161 |
162 |
163 |

164 | DSA (Data Structures and Algorithms) in Python is a fundamental course 165 | that introduces the principles and implementation of various data 166 | structures and algorithms using the Python programming language. 167 |

168 | 169 |

170 | In this course, you will learn about essential data structures such as 171 | arrays, linked lists, stacks, queues, trees, graphs, and hash tables, 172 | and explore their strengths and weaknesses in different scenarios. You 173 | will understand how to manipulate and organize data efficiently, 174 | improving the performance of your programs. 175 |

176 | 177 |

178 | Additionally, the course delves into algorithm analysis and design 179 | techniques, enabling you to create efficient solutions for a wide 180 | range of problems. You will explore algorithms like sorting, 181 | searching, graph traversal, and dynamic programming. By understanding 182 | the underlying concepts, you will be able to write clean and optimized 183 | code. 184 |

185 | 186 |

187 | Throughout the course, you will gain hands-on experience by 188 | implementing data structures and algorithms in Python. The practical 189 | exercises and coding assignments will reinforce your understanding and 190 | help you develop problem-solving skills. 191 |

192 | 193 |

194 | Whether you are a beginner or an experienced programmer, this DSA 195 | course in Python will equip you with the necessary tools and knowledge 196 | to tackle complex programming challenges, enhance your logical 197 | thinking, and become a more proficient developer. 198 |

199 |
200 |

A Very Short Story

201 |
202 |

203 | Once upon a time, a skilled architect named Alice faced a challenge 204 | while designing a bakery's order management system. Reflecting on her 205 | past experience of choosing wooden blocks for a window in her home, 206 | she realized the importance of selecting the perfect data structure. 207 | Inspired by the flexibility and adaptability of wooden blocks, she 208 | opted for a priority queue to efficiently manage the bakery's orders. 209 | Her decision proved to be a game-changer, streamlining operations and 210 | delighting customers. Alice's ability to draw from past experiences 211 | and choose the right data structure showcased her problem-solving 212 | prowess. 213 |

214 |
215 |
216 | 217 |
218 |
219 |

220 | As per the above image you will never use bricks to build a window, 221 | like that as a Software Engineer , you have to choose the perfect Data 222 | Structures to solve a problem. 223 |

224 |
225 |
226 |

227 | Now look at this picture very carefully... 228 |

229 |
230 |
231 | 232 |
233 |
234 |

235 | This is the solution for the problem... 236 |

237 |
238 |
239 | 240 |
241 |
242 |

243 | Some Very Popular Data Structures In Different Programming Languages 244 |

245 |
246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 262 | 267 | 268 | 269 | 270 | 271 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 |
Data StructurePythonJavaC++
ArrayLists 258 | Native Array 259 |
260 | ArrayList 261 |
263 | Native Array 264 |
265 | std::vector 266 |
Hash TableDictionary 272 | HashMap
273 | LinkedHashMap 274 |
std::map
Linked ListNot AvailableLinkedListstd::list
285 |
286 |
287 |
288 | 292 | 293 | 294 | 295 | -------------------------------------------------------------------------------- /lesson-03/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Learn DSA Using Python || Code Explorer 11 | 12 | 13 | 14 | Learn DSA Using Python || Lesson 03 - Data Structures || Code 15 | Explorer 16 |
17 |
18 | 25 |
26 |
27 | Contents 28 | 29 | 143 |
144 |
145 |
146 |

147 | Welcome To DSA Complete Course Using Python By Code Explorer 148 |

149 |
150 |

Here We Will Learn About Data Structures

151 |
152 | 156 |
157 |
158 |
159 | Full 161 | PlayList 162 |
163 |
164 |
165 |

What Are Data Structures ??

166 |
167 |

168 | Data structures refer to the fundamental ways of organizing and storing data in a computer's memory to 169 | facilitate efficient manipulation and retrieval of information. These structures provide a systematic 170 | arrangement of data elements, defining the relationships between them and the operations that can be 171 | performed on them. Common data structures include arrays, linked lists, stacks, queues, trees, graphs, 172 | and hash tables, each designed to suit specific data management and processing needs. Choosing the right 173 | data structure is crucial in optimizing algorithms and ensuring optimal performance in software 174 | development and problem-solving. 175 |

176 |
177 |

Two Types Of Data Structures

178 |
179 |

We can divide Data Structures into two parts . Like We have : - Liner Data Structures & Non-Liner Data Structures

182 |

Liner Data Structures

183 |
    184 |
  1. 185 | 1) Array 186 |
  2. 187 |
  3. 188 | 2) Linked List 189 |
  4. 190 |
  5. 191 | 3) Stack 192 |
  6. 193 |
  7. 194 | 4) Queue 195 |
  8. 196 |
  9. 197 | 5) Matrix 198 |
  10. 199 |
200 |

Non-Liner Data Structures

201 |
    202 |
  1. 203 | 1) Binary Tree 204 |
  2. 205 |
  3. 206 | 2) Heap 207 |
  4. 208 |
  5. 209 | 3) Hash Table 210 |
  6. 211 |
  7. 212 | 4) Graph 213 |
  8. 214 |
215 |
216 |

Python Specific Data Structures

217 |
218 |

Python has some by default specific Data Structures like :-

219 |
    220 |
  1. 221 | 1) List 222 |
  2. 223 |
  3. 224 | 2) Tuple 225 |
  4. 226 |
  5. 227 | 3) Dictionary 228 |
  6. 229 |
  7. 230 | 4) Set 231 |
  8. 232 |
233 |

234 | Python allows us to create and use various types of Data Structures and you can control all of 235 | them . 236 |

237 |
238 |

Lists In Python

239 |
240 |

241 | In Python, a list data structure is an ordered collection of elements that can hold items of 242 | different data types, such as integers, strings, or even other lists. Lists are mutable, meaning 243 | their elements can be modified, added, or removed after creation. They are represented using 244 | square brackets [ ] and can be indexed and sliced to access specific elements or subsets of the 245 | list. Python lists offer versatile functionality, making them widely used for data storage, 246 | iteration, and manipulation in various programming tasks. 247 |

248 |

Implementing A Simple List In Python

249 |
250 |
251 |                   
252 |                     # Creating a list
253 |                     my_list = [1, 2, 3, 4, 5]
254 |                     
255 |                     # Accessing elements in the list
256 |                     print("Element at index 0:", my_list[0])   
257 |                     # Output: Element at index 0: 1
258 |                     print("Element at index 2:", my_list[2])   
259 |                     # Output: Element at index 2: 3
260 |                     
261 |                     # Modifying elements in the list
262 |                     my_list[3] = 10
263 |                     print("Modified list:", my_list)          
264 |                     # Output: Modified list: [1, 2, 3, 10, 5]
265 |                     
266 |                     # Appending elements to the list
267 |                     my_list.append(6)
268 |                     print("List after appending 6:", my_list) 
269 |                     # Output: List after appending 6: [1, 2, 3, 10, 5, 6]
270 |                     
271 |                     # Removing elements from the list
272 |                     my_list.remove(3)
273 |                     print("List after removing 3:", my_list)  
274 |                     # Output: List after removing 3: [1, 2, 10, 5, 6]
275 |                     
276 |                     # Slicing the list
277 |                     sliced_list = my_list[1:4]
278 |                     print("Sliced list:", sliced_list)        
279 |                     # Output: Sliced list: [2, 10, 5]
280 |                     
281 |                     # Length of the list
282 |                     length_of_list = len(my_list)
283 |                     print("Length of the list:", length_of_list)  
284 |                     # Output: Length of the list: 5
285 |                     
286 |                   
287 |                 
288 | 289 | 290 |
291 |

In this code, we create a list called my_list and 292 | perform various operations such as 293 | accessing elements using index, modifying elements, appending elements, removing elements, 294 | slicing the list, and finding the length of the list. Lists in Python are very versatile and can 295 | be used in a wide range of scenarios for data storage and manipulation.

296 |
297 |

Nested or Multi Dimensional List

298 |

A nested or multi-dimensional list is a list that 299 | contains other lists as its elements, creating a structure similar to a matrix or an array of 300 | arrays. Each element in the main list can be another list, and these sub-lists can have 301 | different lengths. Here's an example of a 2D nested list in Python:

302 |
303 |
304 |                       
305 |                         # Creating a nested list (2D list)
306 |                         nested_list = [
307 |                             [1, 2, 3],
308 |                             [4, 5, 6],
309 |                             [7, 8, 9]
310 |                         ]
311 |                         
312 |                         # Accessing elements in the nested list
313 |                         print("Element at row 0, column 1:", nested_list[0][1])   
314 |                         # Output: Element at row 0, column 1: 2
315 |                         print("Element at row 2, column 2:", nested_list[2][2])   
316 |                         # Output: Element at row 2, column 2: 9
317 |                         
318 |                         # Modifying elements in the nested list
319 |                         nested_list[1][0] = 10
320 |                         print("Modified nested list:", nested_list)
321 |                         # Output: Modified nested list: [[1, 2, 3], [10, 5, 6], [7, 8, 9]]
322 |                         
323 |                         # Appending a new row to the nested list
324 |                         new_row = [11, 12, 13]
325 |                         nested_list.append(new_row)
326 |                         print("Nested list after appending a new row:", nested_list)
327 |                         # Output: Nested list after appending a new row: 
328 |                         # [[1, 2, 3], [10, 5, 6], [7, 8, 9], [11, 12, 13]]
329 |                         
330 |                         # Slicing the nested list
331 |                         sliced_list = nested_list[1:3]
332 |                         print("Sliced nested list:", sliced_list)
333 |                         # Output: Sliced nested list: [[10, 5, 6], [7, 8, 9]]
334 |                         
335 |                       
336 |                     
337 | 338 | 339 |
340 |

In this example, nested_list is a 2D list with three 341 | rows, and each row is a list itself. We can access elements using two indices, one for the row 342 | and another for the column. The code demonstrates accessing, modifying, appending rows, and 343 | slicing the nested list. Multi-dimensional lists are useful when dealing with data organized in 344 | a grid-like structure, such as matrices or tables.

345 |
346 |

How To Check The Size Of A List ??

347 |
348 |
349 |                         
350 |                             list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, "Bhed"]
351 |                             print(len(list))
352 | 
353 |                             # Output : 15
354 |                         
355 |                       
356 | 357 |
358 |

Using len() function we can easily find the 360 | length / size of any Lists .

361 |
362 |

Concept Of Negative Indexing

363 |

In Python, negative indexing is a concept that allows 364 | you to access elements from the end of a list using negative numbers as indices. Instead of 365 | counting from the beginning (0) like positive indexing, negative indexing starts counting from 366 | the end (-1) of the list. This means that the last element of the list can be accessed using 367 | index -1, the second-to-last element using index -2, and so on. 368 |

369 |

Here's how negative indexing works with a list :- 370 |

371 |
372 |
373 |                         
374 |                             # Creating a list
375 |                             my_list = [10, 20, 30, 40, 50]
376 |                             
377 |                             # Accessing elements using positive indexing
378 |                             print("Element at index 0:", my_list[0])   
379 |                             # Output: Element at index 0: 10
380 |                             print("Element at index 3:", my_list[3])   
381 |                             # Output: Element at index 3: 40
382 |                             
383 |                             # Accessing elements using negative indexing
384 |                             print("Element at index -1:", my_list[-1])   
385 |                             # Output: Element at index -1: 50
386 |                             print("Element at index -3:", my_list[-3])   
387 |                             # Output: Element at index -3: 30
388 |                             
389 |                         
390 |                       
391 | 392 |
393 |

Using negative indexing can be especially useful when 394 | you want to access elements near the end of the list, or when the length of the list is not 395 | known, but you still need to access the last few elements. Negative indexing provides a 396 | convenient and concise way to achieve this without explicitly calculating the positive index 397 | from the length of the list. 398 |

399 |

So, negative indexing is a powerful feature in Python 400 | lists that allows you to access elements from the end of the list using negative numbers as 401 | indices, making it easier and more intuitive to work with lists, especially when dealing with 402 | elements near the end. 403 |

404 |
405 |

Tuples In Python

406 |
407 |

In Python, a tuple is an immutable, ordered collection 408 | of elements enclosed in 409 | parentheses ( ) or created without 410 | any brackets. Unlike lists, tuples cannot be modified after 411 | creation, making them "immutable" data structures. Tuples can hold elements of different data 412 | types, just like lists, but once a tuple is created, its elements and their order cannot be 413 | changed. 414 |

415 |
416 |

Definition Of Tuples

417 |

Tuples in Python are fixed-size, ordered collections of 418 | elements, and are defined by enclosing the elements within parentheses. They provide a way to 419 | group related data together and are commonly used to represent data that should remain constant 420 | throughout the program's execution. The elements in a tuple can be accessed using indexing, 421 | similar to lists. However, since tuples are immutable, you cannot add, remove, or modify 422 | elements once the tuple is created, which makes them suitable for situations where data 423 | integrity and protection against accidental changes are desired. Tuples are commonly used to 424 | return multiple values from functions, as dictionary keys (since they are immutable), and as 425 | elements of sets, where only immutable objects are allowed. 426 |

427 |
428 |

Implementations Of Tuple In Python

429 |
430 |
431 |                   
432 |                     # Creating a tuple
433 |                     my_tuple = (1, 2, 3, 'apple', 'banana')
434 |                     
435 |                     # Accessing elements in the tuple
436 |                     print("Element at index 0:", my_tuple[0])     
437 |                     # Output: Element at index 0: 1
438 |                     print("Element at index 3:", my_tuple[3])     
439 |                     # Output: Element at index 3: apple
440 |                     
441 |                     # Length of the tuple
442 |                     length_of_tuple = len(my_tuple)
443 |                     print("Length of the tuple:", length_of_tuple)    
444 |                     # Output: Length of the tuple: 5
445 |                     
446 |                     # Iterating over the tuple
447 |                     print("All elements in the tuple:")
448 |                     for item in my_tuple:
449 |                         print(item)
450 |                     # Output:
451 |                     # 1
452 |                     # 2
453 |                     # 3
454 |                     # apple
455 |                     # banana
456 |                     
457 |                   
458 |                 
459 | 460 | 461 |
462 |

In this example, my_tuple is a simple tuple containing 463 | integer and string elements. We access elements using indexing, find the length of the tuple, 464 | and iterate through all the elements using a for loop. Once a tuple is created, its elements 465 | cannot be changed, added, or removed, ensuring its immutability. Tuples are useful for scenarios 466 | where you need to store a fixed set of related data that should not be altered during the 467 | program's execution. 468 |

469 | 470 |
471 |

Immutable Property Of Tuples

472 |

Let's demonstrate the immutable property of tuples by 473 | attempting to modify a tuple after it has been created. This will result in a TypeError since 475 | tuples cannot be changed once they are defined.

476 |
477 |
478 |           
479 |             # Creating a tuple
480 |             my_tuple = (1, 2, 3)
481 |             
482 |             # Attempting to modify the tuple
483 |             try:
484 |                 my_tuple[1] = 10
485 |                 # Trying to change the element at index 1 to 10
486 |             except TypeError as e:
487 |                 print("TypeError:", e)
488 |                 # Output: TypeError: 'tuple' object does not support item assignment
489 |             
490 |           
491 |         
492 | 493 | 494 |
495 |

As shown in the code, when we try to modify the element 496 | at index 1 of the tuple my_tuple, Python raises a TypeError with the message " 'tuple' object 497 | does not support item assignment." This error indicates that tuples are immutable and cannot be 498 | changed after creation. 499 |

500 | 501 |

This is in contrast to lists, where you can modify, 502 | add, or remove elements freely. The immutability of tuples makes them suitable for situations 503 | where you want to ensure data integrity and protect against unintended changes to the data. 504 |

505 | 506 |
507 | 508 |
509 |

510 | Dictionary In Python 511 |

512 |
513 |

In Python, a dictionary is an unordered, mutable 514 | collection of key-value pairs, where each key must be unique. Dictionaries are represented using 515 | curly braces { } and allow for efficient data retrieval and 516 | modification based on their keys. 517 | Each key is associated with a value, and this association is known as a key-value pair. Keys in 518 | dictionaries must be immutable objects, such as strings, numbers, or tuples, while values can be 519 | of any data type. Dictionaries are widely used in Python for tasks that involve data lookup and 520 | storage, mapping relationships between different elements, and efficiently organizing and 521 | managing data. 522 |

523 |
524 |

Implementations Of Dictionary

525 |
526 |
527 |           
528 |             # Creating a dictionary
529 |             my_dict = {
530 |                 'name': 'John',
531 |                 'age': 30,
532 |                 'city': 'New York',
533 |                 'email': 'john@example.com'
534 |             }
535 |             
536 |             # Accessing values using keys
537 |             print("Name:", my_dict['name'])       # Output: Name: John
538 |             print("Age:", my_dict['age'])         # Output: Age: 30
539 |             print("City:", my_dict['city'])       # Output: City: New York
540 |             print("Email:", my_dict['email'])     # Output: Email: john@example.com
541 |             
542 |             # Modifying values in the dictionary
543 |             my_dict['age'] = 32
544 |             print("Modified dictionary:", my_dict)
545 |             # Output: Modified dictionary: 
546 |             # {'name': 'John', 'age': 32, 'city': 'New York', 'email': 'john@example.com'}
547 |             
548 |             # Adding new key-value pairs to the dictionary
549 |             my_dict['occupation'] = 'Engineer'
550 |             print("Dictionary with new pair:", my_dict)
551 |             # Output: Dictionary with new pair: 
552 |             # {'name': 'John', 'age': 32, 'city': 'New York', 
553 |                'email': 'john@example.com', 'occupation': 'Engineer'}
554 |             
555 |             # Removing a key-value pair from the dictionary
556 |             del my_dict['email']
557 |             print("Dictionary after removing email:", my_dict)
558 |             # Output: Dictionary after removing email: 
559 |             # {'name': 'John', 'age': 32, 'city': 'New York', 'occupation': 'Engineer'}
560 |             
561 |             # Length of the dictionary
562 |             length_of_dict = len(my_dict)
563 |             print("Length of the dictionary:", length_of_dict)
564 |             # Output: Length of the dictionary: 4
565 |             
566 |           
567 |         
568 | 569 | 570 |
571 |

In this example, my_dict is a dictionary with key-value 572 | pairs representing various information about a person. We access values using their 573 | corresponding keys, modify values, add new key-value pairs, and remove key-value pairs using the 574 | del keyword. Dictionaries are versatile data structures that offer efficient lookup and 575 | manipulation based on their keys, making them valuable for organizing and managing data in 576 | Python programs. 577 |

578 |
579 |

Set In Python

580 |
581 |

In Python, a set is an unordered, mutable collection of 582 | unique elements. Sets are represented using curly braces { } or 583 | the built-in `set()` function. 584 | Unlike lists or tuples, sets do not allow duplicate elements. When you create a set with 585 | duplicate items, Python automatically removes the duplicates, leaving only the unique elements. 586 | Sets are useful for tasks that involve membership tests, removing duplicates from sequences, and 587 | performing mathematical set operations like union, intersection, and difference. Additionally, 588 | since sets only contain unique elements, they are commonly used to find distinct elements in 589 | data collections.

590 |
591 |

Implementations Of Set

592 |
593 |
594 |               
595 |                 # Creating a set using curly braces
596 |                 my_set = {1, 2, 3, 4, 4, 5}   
597 |                 # Note the duplicate element 4, which will be automatically removed
598 |                 print("Set using curly braces:", my_set)  
599 |                 # Output: Set using curly braces: {1, 2, 3, 4, 5}
600 |                 
601 |                 # Creating a set using the set() function
602 |                 another_set = set([3, 4, 5, 6, 7])
603 |                 print("Set using set() function:", another_set)  
604 |                 # Output: Set using set() function: {3, 4, 5, 6, 7}
605 |                 
606 |                 # Adding elements to the set
607 |                 my_set.add(6)
608 |                 my_set.add(7)
609 |                 print("Set after adding elements:", my_set)  
610 |                 # Output: Set after adding elements: {1, 2, 3, 4, 5, 6, 7}
611 |                 
612 |                 # Removing elements from the set
613 |                 my_set.remove(5)
614 |                 print("Set after removing element 5:", my_set)  
615 |                 # Output: Set after removing element 5: {1, 2, 3, 4, 6, 7}
616 |                 
617 |                 # Checking membership in the set
618 |                 print("Is 3 in the set?", 3 in my_set)  
619 |                 # Output: Is 3 in the set? True
620 |                 print("Is 5 in the set?", 5 in my_set)  
621 |                 # Output: Is 5 in the set? False
622 |                 
623 |                 # Set operations
624 |                 set_a = {1, 2, 3, 4, 5}
625 |                 set_b = {4, 5, 6, 7, 8}
626 |                 
627 |                 # Union of two sets
628 |                 union_set = set_a.union(set_b)
629 |                 print("Union of sets:", union_set)  
630 |                 # Output: Union of sets: {1, 2, 3, 4, 5, 6, 7, 8}
631 |                 
632 |                 # Intersection of two sets
633 |                 intersection_set = set_a.intersection(set_b)
634 |                 print("Intersection of sets:", intersection_set)  
635 |                 # Output: Intersection of sets: {4, 5}
636 |                 
637 |                 # Difference between two sets
638 |                 difference_set = set_a.difference(set_b)
639 |                 print("Difference of sets:", difference_set)  
640 |                 # Output: Difference of sets: {1, 2, 3}
641 |                 
642 |                 # Removing all elements from the set
643 |                 my_set.clear()
644 |                 print("Set after clearing:", my_set)  
645 |                 # Output: Set after clearing: set()
646 |                 
647 |               
648 |             
649 | 650 | 651 |
652 |

In this code, we first create sets using curly braces 653 | and the set() function. We demonstrate adding and removing elements from the set, checking 654 | membership using the in keyword, and performing set operations like union, intersection, and 655 | difference. Sets are versatile data structures, especially useful when you need to handle unique 656 | elements and perform set operations efficiently. 657 |

658 |
659 |
660 | Take Quiz 661 |
662 |
663 |
664 |
665 | 669 | 670 | 671 | 672 | 673 | -------------------------------------------------------------------------------- /lesson-03/quiz.css: -------------------------------------------------------------------------------- 1 | /* Quiz question */ 2 | .quiz-question { 3 | font-size: 24px; 4 | font-weight: bold; 5 | margin-bottom: 20px; 6 | } 7 | 8 | /* Quiz options */ 9 | .quiz-options { 10 | display: flex; 11 | flex-direction: column; 12 | margin-left: 50px; 13 | margin-right: 50px; 14 | } 15 | 16 | .quiz-options li { 17 | display: flex; 18 | align-items: baseline; 19 | font-size: 18px; 20 | margin-bottom: 20px; 21 | flex-direction: row; 22 | flex-wrap: nowrap; 23 | align-content: center; 24 | justify-content: space-between; 25 | } 26 | 27 | .quiz-options input[type="radio"] { 28 | margin-right: 10px; 29 | cursor: pointer; 30 | transform: scale(1.5); 31 | } 32 | 33 | /* Quiz buttons */ 34 | .quiz-buttons { 35 | display: flex; 36 | justify-content: space-between; 37 | margin-top: 20px; 38 | } 39 | 40 | .quiz-buttons button { 41 | padding: 10px 20px; 42 | font-size: 16px; 43 | border: none; 44 | border-radius: 5px; 45 | color: #fff; 46 | cursor: pointer; 47 | transition: background-color 0.3s; 48 | } 49 | 50 | .quiz-buttons button#save-next-btn { 51 | margin-right: 50px; 52 | margin-left: 50px; 53 | margin-bottom: 30px; 54 | background-color: #007bff; 55 | } 56 | 57 | .quiz-buttons button#save-next-btn:hover { 58 | background-color: #0056b3; 59 | } 60 | 61 | .quiz-buttons button#previous-btn { 62 | margin-left: 50px; 63 | margin-bottom: 30px; 64 | background-color: #6c757d; 65 | } 66 | 67 | .quiz-buttons button#previous-btn:hover { 68 | background-color: #4d545b; 69 | } 70 | 71 | /* Quiz result */ 72 | #quiz-result { 73 | text-align: center; 74 | display: none; 75 | margin-top: 30px; 76 | } 77 | 78 | #result-text { 79 | font-size: 20px; 80 | font-weight: bold; 81 | } -------------------------------------------------------------------------------- /lesson-03/quiz.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Learn DSA Using Python || Code Explorer 11 | 12 | 13 | 14 | Learn DSA Using Python || Lesson 03 - Data Structures || Code 15 | Explorer 16 |
17 |
18 | 25 |
26 |
27 | Contents 28 | 29 | 143 |
144 |
145 |
146 |

147 | Welcome To DSA Complete Course Using Python By Code Explorer 148 |

149 |
150 |

Here We Will Take A Small Quiz About Data Structures

151 |
152 |
153 |

154 |
    155 | 156 |
157 |
158 | 159 | 160 |
161 |
162 | 166 | Thanks For Taking Part In The Quiz 167 |
168 |
169 | 173 | 174 | 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /lesson-03/quiz.js: -------------------------------------------------------------------------------- 1 | const quizData = [ 2 | { 3 | question: "Which data structure in Python is used to store elements in key-value pairs?", 4 | options: [ 5 | "A. list", 6 | "B. tuple", 7 | "C. set", 8 | "D. dictionary", 9 | ], 10 | correct: "D", 11 | }, 12 | { 13 | question: "What is the time complexity for searching an element in a dictionary?", 14 | options: [ 15 | "A. O(1)", 16 | "B. O(log n)", 17 | "C. O(n)", 18 | "D. O(n log n)", 19 | ], 20 | correct: "A", 21 | }, 22 | { 23 | question: "Which data structure in Python is used to store an ordered collection of elements?", 24 | options: [ 25 | "A. list", 26 | "B. tuple", 27 | "C. set", 28 | "D. dictionary", 29 | ], 30 | correct: "A", 31 | }, 32 | { 33 | question: "What is the time complexity for inserting an element at the end of a list?", 34 | options: [ 35 | "A. O(1)", 36 | "B. O(log n)", 37 | "C. O(n)", 38 | "D. O(n log n)", 39 | ], 40 | correct: "A", 41 | }, 42 | { 43 | question: "Which data structure in Python is used to store a collection of unique elements?", 44 | options: [ 45 | "A. list", 46 | "B. tuple", 47 | "C. set", 48 | "D. dictionary", 49 | ], 50 | correct: "C", 51 | }, 52 | { 53 | question: "What is the time complexity for removing an element from a set?", 54 | options: [ 55 | "A. O(1)", 56 | "B. O(log n)", 57 | "C. O(n)", 58 | "D. O(n log n)", 59 | ], 60 | correct: "A", 61 | }, 62 | { 63 | question: "In Python, how do you initialize an empty list?", 64 | options: [ 65 | "A. list()", 66 | "B. []", 67 | "C. new List()", 68 | "D. emptyList[]", 69 | ], 70 | correct: "B", 71 | }, 72 | { 73 | question: "What is the time complexity for searching an element in a list?", 74 | options: [ 75 | "A. O(1)", 76 | "B. O(log n)", 77 | "C. O(n)", 78 | "D. O(n log n)", 79 | ], 80 | correct: "C", 81 | }, 82 | { 83 | question: "Which data structure in Python is used to store a collection of elements with no duplicate values?", 84 | options: [ 85 | "A. list", 86 | "B. tuple", 87 | "C. set", 88 | "D. dictionary", 89 | ], 90 | correct: "C", 91 | }, 92 | { 93 | question: "What is the time complexity for inserting an element in the middle of a list?", 94 | options: [ 95 | "A. O(1)", 96 | "B. O(log n)", 97 | "C. O(n)", 98 | "D. O(n log n)", 99 | ], 100 | correct: "C", 101 | }, 102 | { 103 | question: "Which data structure in Python is used to store a sequence of elements that can be changed (mutable)?", 104 | options: [ 105 | "A. list", 106 | "B. tuple", 107 | "C. set", 108 | "D. dictionary", 109 | ], 110 | correct: "A", 111 | }, 112 | { 113 | question: "Which data structure in Python is used to store elements in the order they are inserted?", 114 | options: [ 115 | "A. list", 116 | "B. tuple", 117 | "C. set", 118 | "D. dictionary", 119 | ], 120 | correct: "A", 121 | }, 122 | { 123 | question: "What is the time complexity for inserting an element at the beginning of a list?", 124 | options: [ 125 | "A. O(1)", 126 | "B. O(log n)", 127 | "C. O(n)", 128 | "D. O(n log n)", 129 | ], 130 | correct: "C", 131 | }, 132 | { 133 | question: "Which data structure in Python is used to store an unordered collection of elements?", 134 | options: [ 135 | "A. list", 136 | "B. tuple", 137 | "C. set", 138 | "D. dictionary", 139 | ], 140 | correct: "C", 141 | }, 142 | { 143 | question: "What is the time complexity for removing an element from the beginning of a list?", 144 | options: [ 145 | "A. O(1)", 146 | "B. O(log n)", 147 | "C. O(n)", 148 | "D. O(n log n)", 149 | ], 150 | correct: "C", 151 | }, 152 | { 153 | question: "Which data structure in Python is used to store elements as key-value pairs with unique keys?", 154 | options: [ 155 | "A. list", 156 | "B. tuple", 157 | "C. set", 158 | "D. dictionary", 159 | ], 160 | correct: "D", 161 | }, 162 | { 163 | question: "What is the time complexity for searching an element in a set?", 164 | options: [ 165 | "A. O(1)", 166 | "B. O(log n)", 167 | "C. O(n)", 168 | "D. O(n log n)", 169 | ], 170 | correct: "A", 171 | }, 172 | { 173 | question: "In Python, how do you initialize an empty set?", 174 | options: [ 175 | "A. set()", 176 | "B. {}", 177 | "C. new Set()", 178 | "D. emptySet{}", 179 | ], 180 | correct: "A", 181 | }, 182 | { 183 | question: "What is the time complexity for searching an element in a tuple?", 184 | options: [ 185 | "A. O(1)", 186 | "B. O(log n)", 187 | "C. O(n)", 188 | "D. O(n log n)", 189 | ], 190 | correct: "C", 191 | }, 192 | { 193 | question: "Which data structure in Python is used to store elements in a sorted order?", 194 | options: [ 195 | "A. list", 196 | "B. tuple", 197 | "C. set", 198 | "D. dictionary", 199 | ], 200 | correct: "A", 201 | }, 202 | { 203 | question: "What is the time complexity for removing an element from a tuple?", 204 | options: [ 205 | "A. O(1)", 206 | "B. O(log n)", 207 | "C. O(n)", 208 | "D. O(n log n)", 209 | ], 210 | correct: "C", 211 | }, 212 | { 213 | question: "Which Python method is used to add elements to a set?", 214 | options: [ 215 | "A. push()", 216 | "B. insert()", 217 | "C. add()", 218 | "D. append()", 219 | ], 220 | correct: "C", 221 | }, 222 | { 223 | question: "What is the time complexity for searching an element in a dictionary?", 224 | options: [ 225 | "A. O(1)", 226 | "B. O(log n)", 227 | "C. O(n)", 228 | "D. O(n log n)", 229 | ], 230 | correct: "A", 231 | }, 232 | { 233 | question: "In Python, how do you initialize an empty dictionary?", 234 | options: [ 235 | "A. dict()", 236 | "B. {}", 237 | "C. new Dictionary()", 238 | "D. emptyDict{}", 239 | ], 240 | correct: "A", 241 | }, 242 | { 243 | question: "What is the time complexity for inserting an element in a set?", 244 | options: [ 245 | "A. O(1)", 246 | "B. O(log n)", 247 | "C. O(n)", 248 | "D. O(n log n)", 249 | ], 250 | correct: "A", 251 | }, 252 | { 253 | question: "Which Python method is used to remove elements from a set?", 254 | options: [ 255 | "A. pop()", 256 | "B. remove()", 257 | "C. delete()", 258 | "D. discard()", 259 | ], 260 | correct: "B", 261 | }, 262 | { 263 | question: "What is the time complexity for inserting an element in a dictionary?", 264 | options: [ 265 | "A. O(1)", 266 | "B. O(log n)", 267 | "C. O(n)", 268 | "D. O(n log n)", 269 | ], 270 | correct: "A", 271 | }, 272 | { 273 | question: "Which Python method is used to access elements in a dictionary?", 274 | options: [ 275 | "A. get()", 276 | "B. access()", 277 | "C. fetch()", 278 | "D. retrieve()", 279 | ], 280 | correct: "A", 281 | }, 282 | { 283 | question: "What is the time complexity for removing an element from a dictionary?", 284 | options: [ 285 | "A. O(1)", 286 | "B. O(log n)", 287 | "C. O(n)", 288 | "D. O(n log n)", 289 | ], 290 | correct: "A", 291 | }, 292 | { 293 | question: "Which Python method is used to check if a key exists in a dictionary?", 294 | options: [ 295 | "A. check()", 296 | "B. exists()", 297 | "C. has_key()", 298 | "D. in", 299 | ], 300 | correct: "D", 301 | }, 302 | { 303 | question: "What is the time complexity for updating an element in a list?", 304 | options: [ 305 | "A. O(1)", 306 | "B. O(log n)", 307 | "C. O(n)", 308 | "D. O(n log n)", 309 | ], 310 | correct: "A", 311 | }, 312 | { 313 | question: "Which Python method is used to check if a value exists in a set?", 314 | options: [ 315 | "A. contains()", 316 | "B. in", 317 | "C. has_value()", 318 | "D. check()", 319 | ], 320 | correct: "B", 321 | }, 322 | { 323 | question: "What is the time complexity for updating an element in a set?", 324 | options: [ 325 | "A. O(1)", 326 | "B. O(log n)", 327 | "C. O(n)", 328 | "D. O(n log n)", 329 | ], 330 | correct: "C", 331 | }, 332 | { 333 | question: "Which Python method is used to find the number of elements in a set?", 334 | options: [ 335 | "A. length()", 336 | "B. size()", 337 | "C. count()", 338 | "D. len()", 339 | ], 340 | correct: "D", 341 | }, 342 | { 343 | question: "What is the time complexity for updating an element in a dictionary?", 344 | options: [ 345 | "A. O(1)", 346 | "B. O(log n)", 347 | "C. O(n)", 348 | "D. O(n log n)", 349 | ], 350 | correct: "A", 351 | }, 352 | { 353 | question: "Which Python method is used to find the sum of elements in a list?", 354 | options: [ 355 | "A. sum()", 356 | "B. total()", 357 | "C. add()", 358 | "D. calculate()", 359 | ], 360 | correct: "A", 361 | }, 362 | { 363 | question: "What is the time complexity for updating an element in a tuple?", 364 | options: [ 365 | "A. O(1)", 366 | "B. O(log n)", 367 | "C. O(n)", 368 | "D. O(n log n)", 369 | ], 370 | correct: "C", 371 | }, 372 | { 373 | question: "Which Python method is used to find the maximum element in a set?", 374 | options: [ 375 | "A. max()", 376 | "B. maximum()", 377 | "C. largest()", 378 | "D. get_max()", 379 | ], 380 | correct: "A", 381 | }, 382 | { 383 | question: "What is the time complexity for updating an element in a dictionary?", 384 | options: [ 385 | "A. O(1)", 386 | "B. O(log n)", 387 | "C. O(n)", 388 | "D. O(n log n)", 389 | ], 390 | correct: "A", 391 | }, 392 | { 393 | question: "Which Python method is used to find the minimum element in a list?", 394 | options: [ 395 | "A. min()", 396 | "B. minimum()", 397 | "C. smallest()", 398 | "D. get_min()", 399 | ], 400 | correct: "A", 401 | }, 402 | { 403 | question: "What is the time complexity for updating an element in a set?", 404 | options: [ 405 | "A. O(1)", 406 | "B. O(log n)", 407 | "C. O(n)", 408 | "D. O(n log n)", 409 | ], 410 | correct: "C", 411 | }, 412 | { 413 | question: "Which Python method is used to find the average of elements in a list?", 414 | options: [ 415 | "A. avg()", 416 | "B. mean()", 417 | "C. average()", 418 | "D. calculate_mean()", 419 | ], 420 | correct: "B", 421 | }, 422 | { 423 | question: "Which data structure in Python is used to implement a Last-In-First-Out (LIFO) order?", 424 | options: [ 425 | "A. list", 426 | "B. tuple", 427 | "C. set", 428 | "D. stack", 429 | ], 430 | correct: "D", 431 | }, 432 | { 433 | question: "What is the time complexity for inserting an element at the top of a stack?", 434 | options: [ 435 | "A. O(1)", 436 | "B. O(log n)", 437 | "C. O(n)", 438 | "D. O(n log n)", 439 | ], 440 | correct: "A", 441 | }, 442 | { 443 | question: "Which data structure in Python is used to implement a First-In-First-Out (FIFO) order?", 444 | options: [ 445 | "A. list", 446 | "B. tuple", 447 | "C. set", 448 | "D. queue", 449 | ], 450 | correct: "D", 451 | }, 452 | { 453 | question: "What is the time complexity for inserting an element at the end of a queue?", 454 | options: [ 455 | "A. O(1)", 456 | "B. O(log n)", 457 | "C. O(n)", 458 | "D. O(n log n)", 459 | ], 460 | correct: "A", 461 | }, 462 | { 463 | question: "Which data structure in Python is used to implement a priority queue?", 464 | options: [ 465 | "A. list", 466 | "B. tuple", 467 | "C. set", 468 | "D. heapq", 469 | ], 470 | correct: "D", 471 | }, 472 | { 473 | question: "What is the time complexity for inserting an element into a priority queue?", 474 | options: [ 475 | "A. O(1)", 476 | "B. O(log n)", 477 | "C. O(n)", 478 | "D. O(n log n)", 479 | ], 480 | correct: "B", 481 | }, 482 | { 483 | question: "Which data structure in Python is used to store a collection of elements with no duplicates?", 484 | options: [ 485 | "A. list", 486 | "B. tuple", 487 | "C. set", 488 | "D. dictionary", 489 | ], 490 | correct: "C", 491 | }, 492 | { 493 | question: "What is the time complexity for searching an element in a set?", 494 | options: [ 495 | "A. O(1)", 496 | "B. O(log n)", 497 | "C. O(n)", 498 | "D. O(n log n)", 499 | ], 500 | correct: "A", 501 | }, 502 | { 503 | question: "In Python, how do you initialize an empty set?", 504 | options: [ 505 | "A. set()", 506 | "B. {}", 507 | "C. new Set()", 508 | "D. emptySet{}", 509 | ], 510 | correct: "A", 511 | }, 512 | { 513 | question: "Which data structure in Python is used to implement a graph?", 514 | options: [ 515 | "A. list", 516 | "B. tuple", 517 | "C. set", 518 | "D. dictionary", 519 | ], 520 | correct: "D", 521 | }, 522 | { 523 | question: "What is the time complexity for inserting an edge in a graph?", 524 | options: [ 525 | "A. O(1)", 526 | "B. O(log n)", 527 | "C. O(n)", 528 | "D. O(n log n)", 529 | ], 530 | correct: "A", 531 | }, 532 | { 533 | question: "Which data structure in Python is used to implement a linked list?", 534 | options: [ 535 | "A. list", 536 | "B. tuple", 537 | "C. set", 538 | "D. LinkedList", 539 | ], 540 | correct: "D", 541 | }, 542 | { 543 | question: "What is the time complexity for inserting an element at the end of a linked list?", 544 | options: [ 545 | "A. O(1)", 546 | "B. O(log n)", 547 | "C. O(n)", 548 | "D. O(n log n)", 549 | ], 550 | correct: "A", 551 | }, 552 | { 553 | question: "Which data structure in Python is used to implement a binary search tree?", 554 | options: [ 555 | "A. list", 556 | "B. tuple", 557 | "C. set", 558 | "D. binarytree", 559 | ], 560 | correct: "D", 561 | }, 562 | { 563 | question: "What is the time complexity for inserting an element in a binary search tree?", 564 | options: [ 565 | "A. O(1)", 566 | "B. O(log n)", 567 | "C. O(n)", 568 | "D. O(n log n)", 569 | ], 570 | correct: "B", 571 | }, 572 | { 573 | question: "Which data structure in Python is used to implement a heap?", 574 | options: [ 575 | "A. list", 576 | "B. tuple", 577 | "C. set", 578 | "D. heapq", 579 | ], 580 | correct: "D", 581 | }, 582 | { 583 | question: "What is the time complexity for inserting an element into a heap?", 584 | options: [ 585 | "A. O(1)", 586 | "B. O(log n)", 587 | "C. O(n)", 588 | "D. O(n log n)", 589 | ], 590 | correct: "B", 591 | }, 592 | { 593 | question: "Which data structure in Python is used to implement a hash table?", 594 | options: [ 595 | "A. list", 596 | "B. tuple", 597 | "C. set", 598 | "D. dictionary", 599 | ], 600 | correct: "D", 601 | }, 602 | // Add more questions here 603 | ]; 604 | 605 | let currentQuestion = 0; 606 | let userAnswers = []; 607 | 608 | const quizContainer = document.getElementById("quiz-container"); 609 | const quizResult = document.getElementById("quiz-result"); 610 | const resultText = document.getElementById("result-text"); 611 | 612 | function showQuestion() { 613 | const quizQuestionElement = document.querySelector(".quiz-question"); 614 | const quizOptionsElement = document.querySelector(".quiz-options"); 615 | const currentQuizData = quizData[currentQuestion]; 616 | 617 | quizQuestionElement.textContent = currentQuizData.question; 618 | 619 | quizOptionsElement.innerHTML = ""; 620 | 621 | currentQuizData.options.forEach((option, index) => { 622 | const li = document.createElement("li"); 623 | li.textContent = option; 624 | const radioInput = document.createElement("input"); 625 | radioInput.type = "radio"; 626 | radioInput.name = "option"; 627 | radioInput.value = String.fromCharCode(65 + index); // A, B, C, D... 628 | if (userAnswers[currentQuestion] === radioInput.value) { 629 | radioInput.checked = true; // Check the selected radio button 630 | } 631 | li.appendChild(radioInput); 632 | quizOptionsElement.appendChild(li); 633 | }); 634 | 635 | // Show or hide "Previous" button 636 | const previousBtn = document.getElementById("previous-btn"); 637 | previousBtn.style.display = currentQuestion === 0 ? "none" : "inline-block"; 638 | 639 | // Show or hide "Save & Next" button 640 | const saveNextBtn = document.getElementById("save-next-btn"); 641 | saveNextBtn.textContent = 642 | currentQuestion === quizData.length - 1 ? "Final Submit" : "Save & Next"; 643 | } 644 | 645 | function saveAndNextQuestion() { 646 | const selectedOption = document.querySelector( 647 | 'input[type="radio"]:checked' 648 | ); 649 | 650 | if (selectedOption) { 651 | userAnswers[currentQuestion] = selectedOption.value; 652 | } 653 | 654 | currentQuestion++; 655 | 656 | if (currentQuestion < quizData.length) { 657 | showQuestion(); 658 | } else { 659 | showResult(); 660 | } 661 | } 662 | 663 | function previousQuestion() { 664 | if (currentQuestion > 0) { 665 | currentQuestion--; 666 | showQuestion(); 667 | } 668 | } 669 | 670 | function showResult() { 671 | const correctAnswers = calculateCorrectAnswers(); 672 | const percentage = ((correctAnswers / quizData.length) * 100).toFixed(2); 673 | 674 | quizContainer.style.display = "none"; 675 | quizResult.style.display = "block"; 676 | resultText.textContent = `You got ${correctAnswers} out of ${quizData.length} questions correct. Your score: ${percentage}%`; 677 | } 678 | 679 | function calculateCorrectAnswers() { 680 | let correctCount = 0; 681 | for (let i = 0; i < quizData.length; i++) { 682 | if (userAnswers[i] === quizData[i].correct) { 683 | correctCount++; 684 | } 685 | } 686 | return correctCount; 687 | } 688 | 689 | showQuestion(); 690 | -------------------------------------------------------------------------------- /lesson-03/script.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", function () { 2 | const screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 3 | const dropdownElement = document.querySelector(".dropdown"); 4 | const navElement = document.querySelector(".hide-on-small-screen ul"); 5 | 6 | if (screenWidth <= 760) { 7 | const menuImgSrc = "../images/menu.png"; // Replace with the actual menu image source 8 | const crossImgSrc = "../images/cross.png"; // Replace with the actual cross image source 9 | 10 | const imgElement = document.createElement("img"); 11 | imgElement.src = menuImgSrc; 12 | imgElement.alt = "Menu"; 13 | imgElement.style.height = "60px"; 14 | imgElement.style.width = "60px"; 15 | 16 | dropdownElement.appendChild(imgElement); 17 | 18 | dropdownElement.addEventListener("click", function () { 19 | navElement.classList.toggle("nav-hidden"); 20 | navElement.classList.toggle("nav-visible"); 21 | imgElement.src = navElement.classList.contains("nav-visible") ? crossImgSrc : menuImgSrc; 22 | imgElement.alt = navElement.classList.contains("nav-visible") ? "Cross" : "Menu"; 23 | }); 24 | } 25 | }); 26 | 27 | // Initialize Prism.js 28 | Prism.highlightAll(); 29 | 30 | function copyCode() { 31 | const codeBlock = document.getElementById("code-block"); 32 | navigator.clipboard.writeText(codeBlock.innerText) 33 | .then(() => { 34 | showNotification("Code Copied !!", "success"); 35 | }) 36 | .catch((error) => { 37 | showNotification("Failed To Copy: " + error, "error"); 38 | }); 39 | } 40 | 41 | function copyCode1() { 42 | const codeBlock = document.getElementById("code-block1"); 43 | navigator.clipboard.writeText(codeBlock.innerText) 44 | .then(() => { 45 | showNotification("Code Copied !!", "success"); 46 | }) 47 | .catch((error) => { 48 | showNotification("Failed To Copy: " + error, "error"); 49 | }); 50 | } 51 | 52 | function copyCode2() { 53 | const codeBlock = document.getElementById("code-block2"); 54 | navigator.clipboard.writeText(codeBlock.innerText) 55 | .then(() => { 56 | showNotification("Code Copied !!", "success"); 57 | }) 58 | .catch((error) => { 59 | showNotification("Failed To Copy: " + error, "error"); 60 | }); 61 | } 62 | 63 | function copyCode3() { 64 | const codeBlock = document.getElementById("code-block3"); 65 | navigator.clipboard.writeText(codeBlock.innerText) 66 | .then(() => { 67 | showNotification("Code Copied !!", "success"); 68 | }) 69 | .catch((error) => { 70 | showNotification("Failed To Copy: " + error, "error"); 71 | }); 72 | } 73 | 74 | function copyCode4() { 75 | const codeBlock = document.getElementById("code-block4"); 76 | navigator.clipboard.writeText(codeBlock.innerText) 77 | .then(() => { 78 | showNotification("Code Copied !!", "success"); 79 | }) 80 | .catch((error) => { 81 | showNotification("Failed To Copy: " + error, "error"); 82 | }); 83 | } 84 | 85 | function copyCode5() { 86 | const codeBlock = document.getElementById("code-block5"); 87 | navigator.clipboard.writeText(codeBlock.innerText) 88 | .then(() => { 89 | showNotification("Code Copied !!", "success"); 90 | }) 91 | .catch((error) => { 92 | showNotification("Failed To Copy: " + error, "error"); 93 | }); 94 | } 95 | 96 | function copyCode6() { 97 | const codeBlock = document.getElementById("code-block6"); 98 | navigator.clipboard.writeText(codeBlock.innerText) 99 | .then(() => { 100 | showNotification("Code Copied !!", "success"); 101 | }) 102 | .catch((error) => { 103 | showNotification("Failed To Copy: " + error, "error"); 104 | }); 105 | } 106 | 107 | function copyCode7() { 108 | const codeBlock = document.getElementById("code-block7"); 109 | navigator.clipboard.writeText(codeBlock.innerText) 110 | .then(() => { 111 | showNotification("Code Copied !!", "success"); 112 | }) 113 | .catch((error) => { 114 | showNotification("Failed To Copy: " + error, "error"); 115 | }); 116 | } 117 | 118 | function showNotification(message, type) { 119 | const notification = document.getElementById("notification"); 120 | notification.textContent = message; 121 | notification.classList.add(type, "show"); 122 | 123 | setTimeout(() => { 124 | notification.classList.remove("show"); 125 | }, 3000); 126 | } -------------------------------------------------------------------------------- /lesson-03/style.css: -------------------------------------------------------------------------------- 1 | .container { 2 | max-width: 800px; 3 | margin: 0 auto; 4 | padding: 20px; 5 | } 6 | 7 | pre { 8 | background-color: #080000; 9 | padding: 10px; 10 | overflow-x: auto; 11 | } 12 | 13 | code { 14 | font-family: "Courier New", monospace; 15 | font-size: 14px; 16 | } 17 | 18 | .python { 19 | color: #e83e8c; 20 | } 21 | 22 | .copy-button { 23 | display: inline-block; 24 | background-color: #4caf50; 25 | color: white; 26 | border: none; 27 | padding: 10px 20px; 28 | font-size: 16px; 29 | cursor: pointer; 30 | transition: background-color 0.3s ease; 31 | } 32 | 33 | .copy-button:hover { 34 | background-color: #45a049; 35 | } 36 | 37 | .notification { 38 | position: fixed; 39 | top: 50%; 40 | left: 50%; 41 | transform: translate(-50%, -50%); 42 | background-color: #f44336; 43 | color: white; 44 | padding: 16px; 45 | border-radius: 5px; 46 | visibility: hidden; 47 | opacity: 0; 48 | transition: visibility 0s, opacity 0.3s ease; 49 | } 50 | 51 | .notification.show { 52 | visibility: visible; 53 | opacity: 1; 54 | } -------------------------------------------------------------------------------- /lesson-04/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Learn DSA Using Python || Code Explorer 11 | 12 | 13 | 14 | Learn DSA Using Python || Lesson 04 - Concept Of Algorithms || Code 15 | Explorer 16 |
17 |
18 | 25 |
26 |
27 | Contents 28 | 29 | 143 |
144 |
145 |
146 |

147 | Welcome To DSA Complete Course Using Python By Code Explorer 148 |

149 |
150 |

Here We Will Learn About Algorithms

151 |
152 | 156 |
157 |
158 |
159 | Full 161 | PlayList 162 |
163 |
164 |
165 |

What Are Algorithms ??

166 |
167 |

168 | An algorithm is a step-by-step set of instructions or a well-defined process designed to solve a 169 | specific problem or accomplish a task, often used in computer programming and other fields to achieve 170 | desired outcomes efficiently. 171 |

172 |
173 |

Criteria Of An Algorithm

174 |
175 |
    176 |
  1. 177 | 1 ) 178 | Input 179 |
  2. 180 |
  3. 181 | 2 ) 182 | Output 183 |
  4. 184 |
  5. 185 | 3 ) 186 | Finiteness 187 |
  6. 188 |
  7. 189 | 4 ) 190 | Definiteness 191 |
  8. 192 |
193 |
194 |

When we'll pass the input to an Algorithm , it must give us an 195 | output and this should be a 196 | finite value . And for every programming language the output might be same for a particular input value 197 | .

198 |
199 | 200 |
201 |
202 |

Steps To Implement An Algorithm

203 |
204 |

Implementing an algorithm may sound daunting, but it can be 205 | broken down into simple steps. Here's a beginner-friendly guide to help you get started :-

206 |
    207 |
  1. 208 | 1 ) Understand 209 | The 210 | Problem : 211 |

    Before you begin implementing an algorithm, it's 212 | essential to thoroughly understand the problem you're trying to solve. Clearly define the inputs 213 | and outputs, and consider any constraints that may impact the solution. Gather all the necessary 214 | information and ask questions to gain a comprehensive understanding of the problem at hand.

    215 |
  2. 216 |
  3. 217 | 2 ) Choose An 218 | Algorithm : 219 |

    Selecting the right algorithm is crucial for solving 220 | the problem efficiently. There are various algorithms available for different tasks, such as 221 | searching, sorting, or graph traversal. Research and choose an algorithm that fits your specific 222 | requirements and is well-suited to the nature of the problem.

    223 |
  4. 224 |
  5. 225 | 3 ) Break It 226 | Down : 227 |

    Algorithms can often be complex, so it's helpful to 228 | break them down into smaller, more manageable steps. This process involves understanding each 229 | step and how they work together to achieve the desired solution. Creating flowcharts or diagrams 230 | can be beneficial in visualizing the algorithm's workflow.

    231 |
  6. 232 |
  7. 233 | 4 ) Pseudo Code 234 | : 235 |

    Pseudo code is an intermediate step between 236 | understanding the algorithm and writing actual code. It involves writing the algorithm in 237 | human-readable terms, without worrying about the specific syntax of a programming language. 238 | Pseudo code helps to solidify the logic and approach before diving into the code.

    239 |
  8. 240 |
  9. 241 | 5 ) Choose A 242 | Programming Language : 243 |

    Once you have a clear understanding of the algorithm 244 | and have outlined it in pseudo code, it's time to choose a programming language for 245 | implementation. The choice of language depends on your familiarity with it and the requirements 246 | of your project. Popular languages include Python, Java, C++, and JavaScript.

    247 |
  10. 248 |
  11. 249 | 6 ) Write the 250 | Code : 251 |

    With the pseudo code as a guide, start translating it 252 | into actual code using your chosen programming language. Focus on implementing one step at a 253 | time and test each step thoroughly before proceeding. Building the code incrementally helps in 254 | identifying and fixing issues early on.

    255 |
  12. 256 |
  13. 257 | 7 ) Test 258 | Thoroughly : 259 |

    Testing is a critical phase in the implementation 260 | process. Create test cases that cover various scenarios, including normal cases, edge cases, and 261 | possible errors. By testing rigorously, you can ensure that your algorithm produces accurate 262 | results under different conditions.

    263 |
  14. 264 |
  15. 265 | 8 ) Debug And 266 | Optimize : 267 |

    If your code doesn't work as expected, use debugging 268 | techniques to identify and fix any errors. Additionally, consider optimizing your code to 269 | improve its efficiency, if necessary. Reducing time and memory complexity can make your 270 | algorithm more performant.

    271 |
  16. 272 |
  17. 273 | 9 ) Document Your 274 | Code : 275 |

    Documentation is essential to explain the purpose of 276 | the code and the logic behind it. Add comments and detailed explanations within the code to make 277 | it understandable for yourself and other developers who may work on it in the future.

    278 |
  18. 279 |
  19. 280 | 10 ) Deploy and 281 | Maintain : 282 |

    After successfully implementing and testing your 283 | algorithm, integrate it into your project or application. Be prepared to maintain the code and 284 | make improvements based on user feedback or changing requirements. Software development is an 285 | iterative process, and continuous improvement is key to delivering reliable solutions.

    286 |
  20. 287 |
288 |

Remember that algorithm implementation requires practice and 289 | patience. By following these steps and learning from your experiences, you'll become more proficient in 290 | designing and implementing algorithms.

291 |
292 |

Time Complexity

293 |
294 |

Definition Of Time Complexity

295 |

Time complexity is a measure of how the running time of an 296 | algorithm increases with the size of its input data. It helps us understand the efficiency of an 297 | algorithm and how it scales as the problem size grows. Time complexity is usually expressed using big-O 298 | notation, which provides an upper bound on the growth rate of an algorithm's running time concerning the 299 | input size.

300 |
301 |

Definition Of Big-O Notation

302 |

Big-O notation, often written as O(f(n)), is a mathematical 303 | notation used to describe the upper bound of the growth rate of a function or an algorithm. In the 304 | context of time complexity, 'f(n)' represents the number of operations an algorithm performs concerning 305 | the size of its input 'n'. Big-O notation allows us to compare and analyze algorithms' efficiency and 306 | identify which algorithms are more scalable and better suited for larger data sets.

307 |
308 |

Question Of Time Complexity

309 |

Write a Python function to calculate the sum of elements in 310 | an array. Analyze the time complexity of the 311 | function and calculate its O notation. Provide a simple example demonstrating how the function performs 312 | with different array sizes.

313 |

314 | Let's go step by step to implement the Python function to calculate the sum of elements in an 315 | array and then analyze its time complexity.

316 |

317 | Step 1: Define the function and initialize the `total` variable to zero.

318 |
319 |
320 |                     
321 |                         def sum_array(arr):
322 |                         total = 0
323 |                     
324 |                   
325 | 326 |
327 | 328 |

329 | Step 2: Use a loop to iterate through each element in the array and add it to the `total`.

330 |
331 |
332 |                     
333 |                         for num in arr:
334 |                         total += num
335 |                     
336 |                   
337 | 338 |
339 |
340 |

341 | Step 3: Return the calculated sum.

342 |
343 |
344 |                     
345 |                         return total
346 |                     
347 |                   
348 | 349 |
350 |

351 | Now that we have implemented the function, let's analyze its time complexity and calculate the O 352 | notation.

353 |
354 |

Time Complexity Analysis

355 | 356 |
    357 |
  1. 358 | - The loop in the function runs once for each element in the array.
  2. 359 |
  3. 360 | - Let's say the array has 'n' elements.
  4. 361 |
  5. 362 | - As the size of the array increases, the number of iterations in the loop also increases linearly 363 | with 364 | 'n'.
  6. 365 |
  7. 366 | - Therefore, the time complexity of this function is O(n) because the running time grows linearly 367 | with 368 | the input size 'n'. 369 |
  8. 370 |
371 |
372 |

Calculation Of O Notation

373 |
    374 |
  1. 375 | - The O notation for this function is O(n) because the loop iterates through each element once, and 376 | the 377 | number of iterations is directly proportional to the size of the array 'n'.
  2. 378 |
  3. 379 | - In big-O notation, we consider the most significant term, which is 'n' in this case, and ignore 380 | constant factors and lower-order terms.
  4. 381 |
382 |

383 | Finally, let's provide a simple example demonstrating how the function performs with different array 384 | sizes :-

385 |
386 |
387 |                 
388 |                     arr = [1, 2, 3, 4, 5]
389 |                     print(sum_array(arr)) # Output: 15
390 |                 
391 |               
392 | 393 |
394 |

395 | As the input array grows larger, the time taken by the `sum_array` function will increase linearly with 396 | the size of the array. For example, if the array has 1000 elements, the function will take approximately 397 | 1000 times longer to complete compared to an array with 10 elements. This demonstrates the linear time 398 | complexity of the function. 399 |

400 |
401 |

Space Complexity

402 |
403 |

Definition Of Space Complexity

404 |

Space complexity is a measure of how much additional memory or 405 | space an algorithm or program requires to solve a problem, based on the size of its input. It helps us 406 | understand the efficiency of an algorithm in terms of memory usage. Space complexity includes all the 407 | extra data structures and variables used during the execution of an algorithm, in addition to the input 408 | data. Similar to time complexity, space complexity is also analyzed using big-O notation to express the 409 | upper bound of the space required concerning the input size. Reducing space complexity is essential to 410 | optimize memory usage and improve the performance of algorithms, especially when dealing with large 411 | datasets or resource-constrained environments.

412 |
413 |

Question Of Space Complexity

414 |

Write a Python function that takes a list of integers as 415 | input and returns the count of unique elements in the list. You are required to solve this problem using 416 | additional space, and your implementation should aim for minimal space complexity. Analyze the space 417 | complexity of your solution and provide a simple example to demonstrate how the function works.

418 |

To count the unique elements in the list while minimizing 419 | space usage, we can use a set data structure. A set is an unordered collection of unique elements. By 420 | converting the input list into a set, we automatically remove any duplicate elements. Then, we can 421 | return the size of the set, which represents the count of unique elements.

422 |
423 |
424 |                     
425 |                         def count_unique_elements(arr):
426 |                             unique_set = set(arr)
427 |                             return len(unique_set)
428 |                     
429 |                   
430 | 431 |
432 |
433 |

Space Complexity Analysis

434 |
    435 |
  1. 436 | - The space complexity of this solution primarily depends on the additional space used to store the 437 | set of unique elements.
  2. 438 |
  3. 439 | - In the worst case, if all elements in the input list are unique, the set will store all 'n' 440 | elements 441 | of the list, resulting in a space complexity of O(n).
  4. 442 |
  5. 443 | - In the best case, if all elements in the input list are duplicates, the set will only store a 444 | single 445 | element, resulting in a space complexity of O(1).
  6. 446 |
  7. 447 | - On average, considering various input scenarios, the space complexity can be approximated as 448 | O(min(n, m)), where 'n' is the size of the input list and 'm' is the count of unique elements in the 449 | list.
  8. 450 |
451 |
452 |

Calculation Of O Notation

453 |

Let's demonstrate the function with a simple example :

454 |
455 |
456 |                 
457 |                     arr = [3, 1, 4, 1, 5, 9, 2, 6, 5]
458 |                     print(count_unique_elements(arr))  # Output: 7
459 |                 
460 |               
461 | 462 |
463 |

In this example, the input list has 9 elements, but there are 464 | only 7 unique elements: [3, 1, 4, 5, 9, 2, 6]. The function will return 7 as the count of unique 465 | elements.

466 |

Overall, by utilizing a set to remove duplicates and counting 467 | the size of the set, this solution efficiently finds the count of unique elements while optimizing space 468 | usage.

469 |
470 |
471 | Take Quiz 472 |
473 |
474 |
475 |
476 | 480 | 481 | 482 | 483 | 484 | -------------------------------------------------------------------------------- /lesson-04/script.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", function () { 2 | const screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 3 | const dropdownElement = document.querySelector(".dropdown"); 4 | const navElement = document.querySelector(".hide-on-small-screen ul"); 5 | 6 | if (screenWidth <= 760) { 7 | const menuImgSrc = "../images/menu.png"; // Replace with the actual menu image source 8 | const crossImgSrc = "../images/cross.png"; // Replace with the actual cross image source 9 | 10 | const imgElement = document.createElement("img"); 11 | imgElement.src = menuImgSrc; 12 | imgElement.alt = "Menu"; 13 | imgElement.style.height = "60px"; 14 | imgElement.style.width = "60px"; 15 | 16 | dropdownElement.appendChild(imgElement); 17 | 18 | dropdownElement.addEventListener("click", function () { 19 | navElement.classList.toggle("nav-hidden"); 20 | navElement.classList.toggle("nav-visible"); 21 | imgElement.src = navElement.classList.contains("nav-visible") ? crossImgSrc : menuImgSrc; 22 | imgElement.alt = navElement.classList.contains("nav-visible") ? "Cross" : "Menu"; 23 | }); 24 | } 25 | }); 26 | 27 | // Initialize Prism.js 28 | Prism.highlightAll(); 29 | 30 | function copyCode() { 31 | const codeBlock = document.getElementById("code-block"); 32 | navigator.clipboard.writeText(codeBlock.innerText) 33 | .then(() => { 34 | showNotification("Code Copied !!", "success"); 35 | }) 36 | .catch((error) => { 37 | showNotification("Failed To Copy: " + error, "error"); 38 | }); 39 | } 40 | 41 | function copyCode1() { 42 | const codeBlock = document.getElementById("code-block1"); 43 | navigator.clipboard.writeText(codeBlock.innerText) 44 | .then(() => { 45 | showNotification("Code Copied !!", "success"); 46 | }) 47 | .catch((error) => { 48 | showNotification("Failed To Copy: " + error, "error"); 49 | }); 50 | } 51 | 52 | function copyCode2() { 53 | const codeBlock = document.getElementById("code-block2"); 54 | navigator.clipboard.writeText(codeBlock.innerText) 55 | .then(() => { 56 | showNotification("Code Copied !!", "success"); 57 | }) 58 | .catch((error) => { 59 | showNotification("Failed To Copy: " + error, "error"); 60 | }); 61 | } 62 | 63 | function copyCode3() { 64 | const codeBlock = document.getElementById("code-block3"); 65 | navigator.clipboard.writeText(codeBlock.innerText) 66 | .then(() => { 67 | showNotification("Code Copied !!", "success"); 68 | }) 69 | .catch((error) => { 70 | showNotification("Failed To Copy: " + error, "error"); 71 | }); 72 | } 73 | 74 | function copyCode4() { 75 | const codeBlock = document.getElementById("code-block4"); 76 | navigator.clipboard.writeText(codeBlock.innerText) 77 | .then(() => { 78 | showNotification("Code Copied !!", "success"); 79 | }) 80 | .catch((error) => { 81 | showNotification("Failed To Copy: " + error, "error"); 82 | }); 83 | } 84 | 85 | function copyCode5() { 86 | const codeBlock = document.getElementById("code-block5"); 87 | navigator.clipboard.writeText(codeBlock.innerText) 88 | .then(() => { 89 | showNotification("Code Copied !!", "success"); 90 | }) 91 | .catch((error) => { 92 | showNotification("Failed To Copy: " + error, "error"); 93 | }); 94 | } 95 | 96 | function copyCode6() { 97 | const codeBlock = document.getElementById("code-block6"); 98 | navigator.clipboard.writeText(codeBlock.innerText) 99 | .then(() => { 100 | showNotification("Code Copied !!", "success"); 101 | }) 102 | .catch((error) => { 103 | showNotification("Failed To Copy: " + error, "error"); 104 | }); 105 | } 106 | 107 | function copyCode7() { 108 | const codeBlock = document.getElementById("code-block7"); 109 | navigator.clipboard.writeText(codeBlock.innerText) 110 | .then(() => { 111 | showNotification("Code Copied !!", "success"); 112 | }) 113 | .catch((error) => { 114 | showNotification("Failed To Copy: " + error, "error"); 115 | }); 116 | } 117 | 118 | function showNotification(message, type) { 119 | const notification = document.getElementById("notification"); 120 | notification.textContent = message; 121 | notification.classList.add(type, "show"); 122 | 123 | setTimeout(() => { 124 | notification.classList.remove("show"); 125 | }, 3000); 126 | } -------------------------------------------------------------------------------- /lesson-04/style.css: -------------------------------------------------------------------------------- 1 | .container { 2 | max-width: 800px; 3 | margin: 0 auto; 4 | padding: 20px; 5 | } 6 | 7 | pre { 8 | background-color: #080000; 9 | padding: 10px; 10 | overflow-x: auto; 11 | } 12 | 13 | code { 14 | font-family: "Courier New", monospace; 15 | font-size: 14px; 16 | } 17 | 18 | .python { 19 | color: #e83e8c; 20 | } 21 | 22 | .copy-button { 23 | display: inline-block; 24 | background-color: #4caf50; 25 | color: white; 26 | border: none; 27 | padding: 10px 20px; 28 | font-size: 16px; 29 | cursor: pointer; 30 | transition: background-color 0.3s ease; 31 | } 32 | 33 | .copy-button:hover { 34 | background-color: #45a049; 35 | } 36 | 37 | .notification { 38 | position: fixed; 39 | top: 50%; 40 | left: 50%; 41 | transform: translate(-50%, -50%); 42 | background-color: #f44336; 43 | color: white; 44 | padding: 16px; 45 | border-radius: 5px; 46 | visibility: hidden; 47 | opacity: 0; 48 | transition: visibility 0s, opacity 0.3s ease; 49 | } 50 | 51 | .notification.show { 52 | visibility: visible; 53 | opacity: 1; 54 | } -------------------------------------------------------------------------------- /lesson-2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Learn DSA Using Python || Code Explorer 11 | 12 | 13 | 14 | Learn DSA Using Python || Lesson 02 - Python Revision || Code 15 | Explorer 16 |
17 |
18 | 25 |
26 |
27 | Contents 28 | 29 | 143 |
144 |
145 |
146 |

147 | Welcome To DSA Complete Course Using Python By Code Explorer 148 |

149 |
150 |

This Is A Quick Revision Of Python For This Course

151 |
152 | 156 |
157 |
158 |
159 | Full 160 | PlayList 161 |
162 |
163 |
164 |

165 | Python is a versatile programming language known for its simplicity 166 | and readability, making it an excellent choice for both beginners and 167 | experienced programmers. It provides an extensive set of libraries and 168 | frameworks that make development faster and more efficient. Moreover, 169 | Python's popularity has grown immensely over the years, making it one 170 | of the most widely used programming languages. 171 |

172 | 173 |

174 | When it comes to Data Structures and Algorithms (DSA), Python offers a 175 | range of built-in data structures and comprehensive libraries that 176 | simplify the implementation of algorithms. These features, combined 177 | with Python's expressive syntax, make it an ideal language for working 178 | with DSA. 179 |

180 | 181 |

182 | Let's explore some of the key aspects of Python programming and its relevance to DSA :- 183 |

184 | 185 |

186 |

    187 |
  1. Readability and 189 | Simplicity: Python emphasizes code readability, utilizing an elegant and intuitive syntax. 190 | This makes it easier to understand and maintain code, especially when dealing with complex data structures and 191 | algorithms. Python's minimalist design philosophy encourages developers to write clean and concise code, 192 | reducing the likelihood of errors and making it easier to reason about DSA implementations. 193 |
  2. 194 |
  3. Data Structures: 196 | Python provides a variety of built-in data 197 | structures, such as lists, tuples, dictionaries, 198 | sets, and more. These data structures are versatile and efficient, allowing you to store and manipulate data 199 | effectively. They serve as the foundation for implementing various algorithms and solving problems 200 | efficiently. 201 |
  4. 202 |
  5. Standard Library and 204 | Third-Party Modules: Python's standard 205 | library includes numerous modules that offer a wide range of functionalities. Many of these modules are 206 | relevant to DSA, providing implementations of common algorithms and data structures. For example, the 207 | "collections" module offers advanced data structures like deque and OrderedDict. Additionally, there are 208 | several popular third-party libraries, such as NumPy, Pandas, and SciPy, which provide powerful tools for 209 | numerical computing, data manipulation, and scientific computing. 210 |
  6. 211 |
  7. Algorithmic 213 | Implementations: Python's flexibility allows for 214 | easy implementation of algorithms. It supports imperative, functional, and object-oriented programming 215 | paradigms, providing developers with various approaches to solving algorithmic problems. Additionally, 216 | Python's dynamic typing and high-level abstractions allow for rapid prototyping and experimentation, enabling 217 | programmers to iterate quickly on algorithmic solutions. 218 |
  8. 219 |
  9. Pythonic Idioms: 221 | Pythonic idioms refer to programming 222 | practices and patterns specific to Python. These idioms emphasize code clarity and readability while 223 | leveraging the language's unique features. By following Pythonic idioms, DSA implementations become more 224 | elegant and concise. For instance, list comprehensions, generators, and context managers are common Pythonic 225 | constructs that can simplify code related to algorithms and data structures. 226 |
  10. 227 |
  11. Testing and 229 | Debugging: Python offers robust testing 230 | frameworks, such as unittest and pytest, which aid in the development and verification of DSA implementations. 231 | These frameworks allow you to write test cases, automate test execution, and easily identify and fix issues. 232 | Python's debugging capabilities, with tools like pdb (Python Debugger), help diagnose and resolve problems 233 | efficiently. 234 |
  12. 235 |
236 |

237 | 238 |

239 | Overall, Python's combination of simplicity, readability, powerful libraries, and vast community support makes 240 | it an excellent choice for implementing data structures and algorithms. Its ecosystem provides ample resources, 241 | tutorials, and documentation to support learning and mastering DSA using Python. 242 |

243 |
244 |

First Python Program

245 |
246 |
247 |
248 |           
249 |               print("Hello, World!")
250 |           
251 |         
252 | 253 | 254 |
255 | 256 |
257 | 258 |
259 |

260 | Variables In Python 261 |

262 |
263 |

Variables are the name , given to a particular memory location. We've 264 | to follow some rule to declare a variable names in Python . Those are :-

265 |

Do This

266 | 1) Starts 267 | with only A-Z / a-z/ _ . 268 |
269 | 2) Can 270 | contain number in the middle. 271 |

Don't Do This

272 | 1) Doesn't 273 | starts with any number (0-9). 274 |
275 | 2) Some 276 | system variables starts with (_) , so we'll avoid that. 277 |

As Python is a Dynamically Typed programming language , we don't need to mention the data type of the 278 | variable . This will automatically detect that .

279 |
280 |

281 | Data Types In Python 282 |

283 |
284 |

We've some by default data-types in Python like,-

285 | 1) 286 | Integer 287 | 2) 288 | Float 289 | 3) 290 | Strings 291 | 4) 292 | Arrays 293 |

To know a data-type of a variable , we can use type() 294 | function .

295 |
296 |

Arithmetical Operators

297 |
298 |

In Python we've some Arithmetical Operators ,-

299 | 1) 300 | [+] 301 | To add two integers / floats / strings 302 |
303 | 1) 304 | [-] 305 | To subtract two integers / floats 306 |
307 | 1) 308 | [*] 309 | To multiply two integers / floats 310 |
311 | 1) 312 | [/] 313 | To divide two integers / floats 314 |
315 | 1) 316 | [**] 317 | To power two integers / floats 318 |
319 | 1) 320 | [//] 321 | To floor division two integers / floats 322 |
323 |

Taking Inputs

324 |
325 |

We've to use input() function to take inputs , from the users 326 | . By default the input() function stores the user input in string 327 | data-type format .

328 |
329 |
330 |             
331 |   def add():
332 |     input1 = input("Enter Your first Number : ")
333 |     input2 = input("Enter Your second Number : ")
334 | 
335 |     output = input1 + input2
336 |     print("The result is " + output)
337 | 
338 |   add()
339 |             
340 |           
341 |
342 |
343 |

This code will store your numbers as string data-type , so it will not add your numbers . But if you 344 | want to add them , you've to convert the data-type to string(str) to integer(int) . Let see how we can do that,- 345 |

346 |
347 |
348 |             
349 |   def add():
350 |     input1 = int(input("Enter Your first Number : "))
351 |     input2 = int(input("Enter Your second Number : "))
352 | 
353 |     output = input1 + input2
354 |     print("The result is " + output)
355 | 
356 |   add()
357 |             
358 |           
359 |
360 |
361 |
362 | Take Quiz 363 |
364 |
365 |
366 |
367 | 371 | 372 | 373 | 374 | 375 | -------------------------------------------------------------------------------- /lesson-2/quiz.css: -------------------------------------------------------------------------------- 1 | /* Quiz question */ 2 | .quiz-question { 3 | font-size: 24px; 4 | font-weight: bold; 5 | margin-bottom: 20px; 6 | } 7 | 8 | /* Quiz options */ 9 | .quiz-options { 10 | display: flex; 11 | flex-direction: column; 12 | margin-left: 50px; 13 | margin-right: 50px; 14 | } 15 | 16 | .quiz-options li { 17 | display: flex; 18 | align-items: baseline; 19 | font-size: 18px; 20 | margin-bottom: 20px; 21 | flex-direction: row; 22 | flex-wrap: nowrap; 23 | align-content: center; 24 | justify-content: space-between; 25 | } 26 | 27 | .quiz-options input[type="radio"] { 28 | margin-right: 10px; 29 | cursor: pointer; 30 | transform: scale(1.5); 31 | } 32 | 33 | /* Quiz buttons */ 34 | .quiz-buttons { 35 | display: flex; 36 | justify-content: space-between; 37 | margin-top: 20px; 38 | } 39 | 40 | .quiz-buttons button { 41 | padding: 10px 20px; 42 | font-size: 16px; 43 | border: none; 44 | border-radius: 5px; 45 | color: #fff; 46 | cursor: pointer; 47 | transition: background-color 0.3s; 48 | } 49 | 50 | .quiz-buttons button#save-next-btn { 51 | margin-right: 50px; 52 | margin-left: 50px; 53 | margin-bottom: 30px; 54 | background-color: #007bff; 55 | } 56 | 57 | .quiz-buttons button#save-next-btn:hover { 58 | background-color: #0056b3; 59 | } 60 | 61 | .quiz-buttons button#previous-btn { 62 | margin-left: 50px; 63 | margin-bottom: 30px; 64 | background-color: #6c757d; 65 | } 66 | 67 | .quiz-buttons button#previous-btn:hover { 68 | background-color: #4d545b; 69 | } 70 | 71 | /* Quiz result */ 72 | #quiz-result { 73 | text-align: center; 74 | display: none; 75 | margin-top: 30px; 76 | } 77 | 78 | #result-text { 79 | font-size: 20px; 80 | font-weight: bold; 81 | } -------------------------------------------------------------------------------- /lesson-2/quiz.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Learn DSA Using Python || Code Explorer 11 | 12 | 13 | 14 | Learn DSA Using Python || Lesson 03 - Data Structures || Code 15 | Explorer 16 |
17 |
18 | 25 |
26 |
27 | Contents 28 | 29 | 143 |
144 |
145 |
146 |

147 | Welcome To DSA Complete Course Using Python By Code Explorer 148 |

149 |
150 |

Here We Will Take A Small Quiz About Basic Python Revision

151 |
152 |
153 |

154 |
    155 | 156 |
157 |
158 | 159 | 160 |
161 |
162 | 166 | Thanks For Taking Part In The Quiz 167 |
168 |
169 | 173 | 174 | 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /lesson-2/quiz.js: -------------------------------------------------------------------------------- 1 | const quizData = [ 2 | { 3 | question: "What is Python?", 4 | options: [ 5 | "A. A high-level programming language", 6 | "B. A software framework", 7 | "C. A hardware device", 8 | "D. A database management system", 9 | ], 10 | correct: "A", 11 | }, 12 | { 13 | question: "Which statement is used to define a function in Python?", 14 | options: [ 15 | "A. define function", 16 | "B. def function", 17 | "C. func", 18 | "D. function()", 19 | ], 20 | correct: "B", 21 | }, 22 | { 23 | question: "What is the output of the following code?\nprint(3 + 2 * 4)", 24 | options: ["A. 20", "B. 14", "C. 11", "D. 10"], 25 | correct: "C", 26 | }, 27 | { 28 | question: "Which data type is used to store a sequence of characters in Python?", 29 | options: ["A. int", "B. str", "C. float", "D. list"], 30 | correct: "B", 31 | }, 32 | { 33 | question: "How do you check the length of a list named 'my_list'?", 34 | options: [ 35 | "A. my_list.length()", 36 | "B. length(my_list)", 37 | "C. len(my_list)", 38 | "D. my_list.size()", 39 | ], 40 | correct: "C", 41 | }, 42 | { 43 | question: "What does the 'range()' function in Python return?", 44 | options: [ 45 | "A. A list of numbers", 46 | "B. A single number", 47 | "C. A tuple", 48 | "D. A string", 49 | ], 50 | correct: "A", 51 | }, 52 | { 53 | question: "In Python, what is the correct way to comment a single line of code?", 54 | options: [ 55 | "A. /* comment */", 56 | "B. // comment", 57 | "C. # comment", 58 | "D. ", 59 | ], 60 | correct: "C", 61 | }, 62 | { 63 | question: "Which loop is used to iterate through a sequence in Python?", 64 | options: ["A. for loop", "B. while loop", "C. do-while loop", "D. repeat-until loop"], 65 | correct: "A", 66 | }, 67 | { 68 | question: "What is the output of the following code?\nprint('Hello' + ' ' + 'World')", 69 | options: [ 70 | "A. HelloWorld", 71 | "B. Hello World", 72 | "C. Hello+World", 73 | "D. Hello World!", 74 | ], 75 | correct: "B", 76 | }, 77 | { 78 | question: "What is the correct way to import a module named 'math' in Python?", 79 | options: [ 80 | "A. import Math", 81 | "B. import math", 82 | "C. import MATH", 83 | "D. import maths", 84 | ], 85 | correct: "B", 86 | }, 87 | { 88 | question: "What is the output of the following code?\nnumbers = [1, 2, 3, 4, 5]\nprint(numbers[2:4])", 89 | options: [ 90 | "A. [1, 2]", 91 | "B. [2, 3, 4]", 92 | "C. [3, 4]", 93 | "D. [4, 5]", 94 | ], 95 | correct: "C", 96 | }, 97 | { 98 | question: "Which Python function is used to sort a list in ascending order?", 99 | options: [ 100 | "A. sort()", 101 | "B. sorted()", 102 | "C. order()", 103 | "D. arrange()", 104 | ], 105 | correct: "B", 106 | }, 107 | { 108 | question: "What is the purpose of the 'elif' keyword in Python?", 109 | options: [ 110 | "A. It defines a new function", 111 | "B. It creates a loop", 112 | "C. It is short for 'else if' and used for multiple conditions", 113 | "D. It is used to comment code", 114 | ], 115 | correct: "C", 116 | }, 117 | { 118 | question: "Which statement is used to raise an exception in Python?", 119 | options: [ 120 | "A. raise exception", 121 | "B. throw exception", 122 | "C. throw new exception", 123 | "D. raise new exception", 124 | ], 125 | correct: "A", 126 | }, 127 | { 128 | question: "In Python, what does the 'pop()' method do on a list?", 129 | options: [ 130 | "A. Removes the last element from the list", 131 | "B. Removes the first element from the list", 132 | "C. Inserts a new element at the beginning of the list", 133 | "D. Inserts a new element at the end of the list", 134 | ], 135 | correct: "A", 136 | }, 137 | { 138 | question: "What is the purpose of the 'pass' keyword in Python?", 139 | options: [ 140 | "A. It defines a function without any implementation", 141 | "B. It terminates the program", 142 | "C. It comments out code", 143 | "D. It is used to skip iterations in a loop", 144 | ], 145 | correct: "A", 146 | }, 147 | { 148 | question: "Which Python library is used for data analysis and manipulation?", 149 | options: [ 150 | "A. pandas", 151 | "B. matplotlib", 152 | "C. numpy", 153 | "D. scipy", 154 | ], 155 | correct: "A", 156 | }, 157 | { 158 | question: "What does the 'lambda' keyword in Python indicate?", 159 | options: [ 160 | "A. A function without a name", 161 | "B. A recursive function", 162 | "C. A generator function", 163 | "D. A built-in function", 164 | ], 165 | correct: "A", 166 | }, 167 | { 168 | question: "In Python, what is the purpose of 'try', 'except', and 'finally' blocks?", 169 | options: [ 170 | "A. They are used for defining loops", 171 | "B. They are used for user input", 172 | "C. They are used for handling exceptions", 173 | "D. They are used for defining classes", 174 | ], 175 | correct: "C", 176 | }, 177 | { 178 | question: "What is the output of the following code?\nprint(type(42))", 179 | options: [ 180 | "A. int", 181 | "B. str", 182 | "C. float", 183 | "D. bool", 184 | ], 185 | correct: "A", 186 | }, 187 | { 188 | question: "What does the 'enumerate()' function in Python do?", 189 | options: [ 190 | "A. Returns the index of the first occurrence of a value in a list", 191 | "B. Iterates over a sequence and returns a tuple containing the index and value", 192 | "C. Returns the total number of elements in a list", 193 | "D. Sorts the elements of a list in descending order", 194 | ], 195 | correct: "B", 196 | }, 197 | { 198 | question: "Which module in Python provides support for working with dates and times?", 199 | options: [ 200 | "A. datetime", 201 | "B. time", 202 | "C. dateutil", 203 | "D. calendar", 204 | ], 205 | correct: "A", 206 | }, 207 | { 208 | question: "What is the output of the following code?\nprint(bool([]))", 209 | options: [ 210 | "A. True", 211 | "B. False", 212 | "C. None", 213 | "D. Error", 214 | ], 215 | correct: "B", 216 | }, 217 | { 218 | question: "What is the purpose of the 'pass' statement in Python?", 219 | options: [ 220 | "A. It defines a new function", 221 | "B. It creates a loop", 222 | "C. It is used as a placeholder for future code", 223 | "D. It is used to skip a single iteration in a loop", 224 | ], 225 | correct: "C", 226 | }, 227 | { 228 | question: "Which Python data structure allows duplicate elements and is mutable?", 229 | options: [ 230 | "A. set", 231 | "B. list", 232 | "C. tuple", 233 | "D. dictionary", 234 | ], 235 | correct: "B", 236 | }, 237 | { 238 | question: "What is the purpose of the 'with' statement in Python?", 239 | options: [ 240 | "A. It is used to define a context manager", 241 | "B. It defines a new function", 242 | "C. It is used for sorting lists", 243 | "D. It is used for handling exceptions", 244 | ], 245 | correct: "A", 246 | }, 247 | { 248 | question: "In Python, what is the purpose of the 'random' module?", 249 | options: [ 250 | "A. To generate random numbers", 251 | "B. To perform mathematical operations", 252 | "C. To manipulate strings", 253 | "D. To define classes", 254 | ], 255 | correct: "A", 256 | }, 257 | { 258 | question: "What is the output of the following code?\nprint(5 > 2 and 3 > 1)", 259 | options: [ 260 | "A. True", 261 | "B. False", 262 | "C. None", 263 | "D. Error", 264 | ], 265 | correct: "A", 266 | }, 267 | { 268 | question: "Which Python statement is used to exit a loop prematurely?", 269 | options: [ 270 | "A. exit", 271 | "B. stop", 272 | "C. break", 273 | "D. continue", 274 | ], 275 | correct: "C", 276 | }, 277 | { 278 | question: "What is the output of the following code?\nprint('Python'.replace('P', 'J'))", 279 | options: [ 280 | "A. Python", 281 | "B. Jython", 282 | "C. JYTHON", 283 | "D. PYthon", 284 | ], 285 | correct: "B", 286 | }, 287 | 288 | { 289 | question: "What is the output of the following code?\nprint(10 / 3)", 290 | options: [ 291 | "A. 3.3333333333333335", 292 | "B. 3.333", 293 | "C. 3", 294 | "D. 3.0", 295 | ], 296 | correct: "A", 297 | }, 298 | { 299 | question: "Which method is used to remove an element by its value from a list in Python?", 300 | options: [ 301 | "A. pop()", 302 | "B. remove()", 303 | "C. delete()", 304 | "D. discard()", 305 | ], 306 | correct: "B", 307 | }, 308 | { 309 | question: "What is the purpose of the 'is' keyword in Python?", 310 | options: [ 311 | "A. It is used to check if two lists have the same elements", 312 | "B. It is used to check if two variables reference the same object", 313 | "C. It is used to compare the lengths of two lists", 314 | "D. It is used to combine two conditions in an if statement", 315 | ], 316 | correct: "B", 317 | }, 318 | { 319 | question: "Which Python module is used for regular expressions?", 320 | options: [ 321 | "A. regex", 322 | "B. re", 323 | "C. regular", 324 | "D. rex", 325 | ], 326 | correct: "B", 327 | }, 328 | { 329 | question: "What is the output of the following code?\nprint('Hello, World!'.split(','))", 330 | options: [ 331 | "A. ['Hello', 'World']", 332 | "B. ['Hello', ', World']", 333 | "C. ['Hello, World!']", 334 | "D. ['Hello, ', 'World!']", 335 | ], 336 | correct: "A", 337 | }, 338 | { 339 | question: "In Python, what is the purpose of the 'map()' function?", 340 | options: [ 341 | "A. To generate a new list containing the results of applying a function to each element of an existing list", 342 | "B. To iterate over two or more lists simultaneously", 343 | "C. To remove elements from a list", 344 | "D. To combine multiple lists into a single list", 345 | ], 346 | correct: "A", 347 | }, 348 | { 349 | question: "Which Python operator is used for exponentiation?", 350 | options: [ 351 | "A. ^", 352 | "B. **", 353 | "C. ^^", 354 | "D. //", 355 | ], 356 | correct: "B", 357 | }, 358 | { 359 | question: "What is the output of the following code?\nprint('python'.capitalize())", 360 | options: [ 361 | "A. PYTHON", 362 | "B. Python", 363 | "C. python", 364 | "D. PYThon", 365 | ], 366 | correct: "B", 367 | }, 368 | { 369 | question: "Which Python data type is ordered and immutable?", 370 | options: [ 371 | "A. list", 372 | "B. tuple", 373 | "C. set", 374 | "D. dictionary", 375 | ], 376 | correct: "B", 377 | }, 378 | { 379 | question: "What is the purpose of the 'filter()' function in Python?", 380 | options: [ 381 | "A. To filter the elements of a list based on a given condition", 382 | "B. To merge two or more lists", 383 | "C. To repeat a block of code", 384 | "D. To sort a list in descending order", 385 | ], 386 | correct: "A", 387 | }, 388 | { 389 | question: "What is the output of the following code?\nprint('Hello' * 3)", 390 | options: [ 391 | "A. Hello", 392 | "B. HelloHelloHello", 393 | "C. 3Hello", 394 | "D. 3", 395 | ], 396 | correct: "B", 397 | }, 398 | { 399 | question: "In Python, what is the purpose of the 'all()' function?", 400 | options: [ 401 | "A. To return the largest item in an iterable", 402 | "B. To check if all elements in an iterable are True", 403 | "C. To return the sum of all elements in an iterable", 404 | "D. To convert an iterable into a list", 405 | ], 406 | correct: "B", 407 | }, 408 | { 409 | question: "What does the 'pass' statement do in Python?", 410 | options: [ 411 | "A. It defines a new function", 412 | "B. It creates a loop", 413 | "C. It is used to define a context manager", 414 | "D. It is used as a placeholder for future code", 415 | ], 416 | correct: "D", 417 | }, 418 | { 419 | question: "Which Python data type is used to store a collection of key-value pairs?", 420 | options: [ 421 | "A. list", 422 | "B. tuple", 423 | "C. set", 424 | "D. dictionary", 425 | ], 426 | correct: "D", 427 | }, 428 | { 429 | question: "What is the purpose of the 'min()' function in Python?", 430 | options: [ 431 | "A. To return the smallest item in an iterable", 432 | "B. To check if all elements in an iterable are True", 433 | "C. To return the sum of all elements in an iterable", 434 | "D. To convert an iterable into a list", 435 | ], 436 | correct: "A", 437 | }, 438 | { 439 | question: "What is the output of the following code?\nprint('Hello, World!'[7:12])", 440 | options: [ 441 | "A. World", 442 | "B. World!", 443 | "C. , Wor", 444 | "D. , World", 445 | ], 446 | correct: "D", 447 | }, 448 | { 449 | question: "Which Python keyword is used to define a block of code that can be called later?", 450 | options: [ 451 | "A. def", 452 | "B. block", 453 | "C. call", 454 | "D. function", 455 | ], 456 | correct: "A", 457 | }, 458 | { 459 | question: "What is the purpose of the 'zip()' function in Python?", 460 | options: [ 461 | "A. To combine two or more lists into a single list", 462 | "B. To iterate over two or more lists simultaneously", 463 | "C. To remove elements from a list", 464 | "D. To sort a list in descending order", 465 | ], 466 | correct: "B", 467 | }, 468 | { 469 | question: "What is the output of the following code?\nprint(2 == '2')", 470 | options: [ 471 | "A. True", 472 | "B. False", 473 | "C. None", 474 | "D. Error", 475 | ], 476 | correct: "B", 477 | }, 478 | { 479 | question: "Which Python function is used to read input from the user?", 480 | options: [ 481 | "A. get_input()", 482 | "B. read_input()", 483 | "C. input()", 484 | "D. user_input()", 485 | ], 486 | correct: "C", 487 | }, 488 | { 489 | question: "What will be the output of the following code snippet?\nmy_list = [1, 2, 3, 4, 5]\nprint(my_list[-2])", 490 | options: [ 491 | "A. 4", 492 | "B. 2", 493 | "C. 5", 494 | "D. 3", 495 | ], 496 | correct: "D", 497 | }, 498 | { 499 | question: "In Python, which data type is used to represent a sequence of characters?", 500 | options: [ 501 | "A. char", 502 | "B. string", 503 | "C. text", 504 | "D. chr", 505 | ], 506 | correct: "B", 507 | }, 508 | { 509 | question: "What is the output of the following code snippet?\nprint(3 * 'abc')", 510 | options: [ 511 | "A. abcabcabc", 512 | "B. abc abc abc", 513 | "C. abc 3", 514 | "D. abc*3", 515 | ], 516 | correct: "A", 517 | }, 518 | { 519 | question: "Which Python function is used to find the length of an object?", 520 | options: [ 521 | "A. length()", 522 | "B. size()", 523 | "C. count()", 524 | "D. len()", 525 | ], 526 | correct: "D", 527 | }, 528 | { 529 | question: "What will be the output of the following code snippet?\nmy_tuple = (1, 2, 3, 4, 5)\nprint(my_tuple[1:4])", 530 | options: [ 531 | "A. (2, 3, 4)", 532 | "B. (1, 2, 3)", 533 | "C. (2, 3)", 534 | "D. (1, 2, 3, 4)", 535 | ], 536 | correct: "A", 537 | }, 538 | { 539 | question: "In Python, which operator is used for exponentiation?", 540 | options: [ 541 | "A. ^", 542 | "B. **", 543 | "C. ^^", 544 | "D. //", 545 | ], 546 | correct: "B", 547 | }, 548 | { 549 | question: "What is the output of the following code snippet?\nprint('Python'[1:-1])", 550 | options: [ 551 | "A. Pyt", 552 | "B. ytho", 553 | "C. thon", 554 | "D. Pyth", 555 | ], 556 | correct: "C", 557 | }, 558 | { 559 | question: "Which Python method is used to convert a string to lowercase?", 560 | options: [ 561 | "A. lower()", 562 | "B. toLowerCase()", 563 | "C. convertToLower()", 564 | "D. lowercase()", 565 | ], 566 | correct: "A", 567 | }, 568 | { 569 | question: "What will be the output of the following code snippet?\nmy_set = {1, 2, 3, 4, 5}\nprint(len(my_set))", 570 | options: [ 571 | "A. 5", 572 | "B. 4", 573 | "C. 1", 574 | "D. 0", 575 | ], 576 | correct: "A", 577 | }, 578 | { 579 | question: "In Python, which data type is used to represent a single, immutable (unchangeable) element?", 580 | options: [ 581 | "A. int", 582 | "B. float", 583 | "C. bool", 584 | "D. tuple", 585 | ], 586 | correct: "D", 587 | }, 588 | // Add more questions here 589 | ]; 590 | 591 | let currentQuestion = 0; 592 | let userAnswers = []; 593 | 594 | const quizContainer = document.getElementById("quiz-container"); 595 | const quizResult = document.getElementById("quiz-result"); 596 | const resultText = document.getElementById("result-text"); 597 | 598 | function showQuestion() { 599 | const quizQuestionElement = document.querySelector(".quiz-question"); 600 | const quizOptionsElement = document.querySelector(".quiz-options"); 601 | const currentQuizData = quizData[currentQuestion]; 602 | 603 | quizQuestionElement.textContent = currentQuizData.question; 604 | 605 | quizOptionsElement.innerHTML = ""; 606 | 607 | currentQuizData.options.forEach((option, index) => { 608 | const li = document.createElement("li"); 609 | li.textContent = option; 610 | const radioInput = document.createElement("input"); 611 | radioInput.type = "radio"; 612 | radioInput.name = "option"; 613 | radioInput.value = String.fromCharCode(65 + index); // A, B, C, D... 614 | if (userAnswers[currentQuestion] === radioInput.value) { 615 | radioInput.checked = true; // Check the selected radio button 616 | } 617 | li.appendChild(radioInput); 618 | quizOptionsElement.appendChild(li); 619 | }); 620 | 621 | // Show or hide "Previous" button 622 | const previousBtn = document.getElementById("previous-btn"); 623 | previousBtn.style.display = currentQuestion === 0 ? "none" : "inline-block"; 624 | 625 | // Show or hide "Save & Next" button 626 | const saveNextBtn = document.getElementById("save-next-btn"); 627 | saveNextBtn.textContent = 628 | currentQuestion === quizData.length - 1 ? "Final Submit" : "Save & Next"; 629 | } 630 | 631 | function saveAndNextQuestion() { 632 | const selectedOption = document.querySelector( 633 | 'input[type="radio"]:checked' 634 | ); 635 | 636 | if (selectedOption) { 637 | userAnswers[currentQuestion] = selectedOption.value; 638 | } 639 | 640 | currentQuestion++; 641 | 642 | if (currentQuestion < quizData.length) { 643 | showQuestion(); 644 | } else { 645 | showResult(); 646 | } 647 | } 648 | 649 | function previousQuestion() { 650 | if (currentQuestion > 0) { 651 | currentQuestion--; 652 | showQuestion(); 653 | } 654 | } 655 | 656 | function showResult() { 657 | const correctAnswers = calculateCorrectAnswers(); 658 | const percentage = ((correctAnswers / quizData.length) * 100).toFixed(2); 659 | 660 | quizContainer.style.display = "none"; 661 | quizResult.style.display = "block"; 662 | resultText.textContent = `You got ${correctAnswers} out of ${quizData.length} questions correct. Your score: ${percentage}%`; 663 | } 664 | 665 | function calculateCorrectAnswers() { 666 | let correctCount = 0; 667 | for (let i = 0; i < quizData.length; i++) { 668 | if (userAnswers[i] === quizData[i].correct) { 669 | correctCount++; 670 | } 671 | } 672 | return correctCount; 673 | } 674 | 675 | showQuestion(); -------------------------------------------------------------------------------- /lesson-2/script.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", function () { 2 | const screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 3 | const dropdownElement = document.querySelector(".dropdown"); 4 | const navElement = document.querySelector(".hide-on-small-screen ul"); 5 | 6 | if (screenWidth <= 760) { 7 | const menuImgSrc = "../images/menu.png"; // Replace with the actual menu image source 8 | const crossImgSrc = "../images/cross.png"; // Replace with the actual cross image source 9 | 10 | const imgElement = document.createElement("img"); 11 | imgElement.src = menuImgSrc; 12 | imgElement.alt = "Menu"; 13 | imgElement.style.height = "60px"; 14 | imgElement.style.width = "60px"; 15 | 16 | dropdownElement.appendChild(imgElement); 17 | 18 | dropdownElement.addEventListener("click", function () { 19 | navElement.classList.toggle("nav-hidden"); 20 | navElement.classList.toggle("nav-visible"); 21 | imgElement.src = navElement.classList.contains("nav-visible") ? crossImgSrc : menuImgSrc; 22 | imgElement.alt = navElement.classList.contains("nav-visible") ? "Cross" : "Menu"; 23 | }); 24 | } 25 | }); 26 | 27 | // Initialize Prism.js 28 | Prism.highlightAll(); 29 | 30 | function copyCode() { 31 | const codeBlock = document.getElementById("code-block"); 32 | navigator.clipboard.writeText(codeBlock.innerText) 33 | .then(() => { 34 | showNotification("Code Copied !!", "success"); 35 | }) 36 | .catch((error) => { 37 | showNotification("Failed To Copy: " + error, "error"); 38 | }); 39 | } 40 | 41 | function showNotification(message, type) { 42 | const notification = document.getElementById("notification"); 43 | notification.textContent = message; 44 | notification.classList.add(type, "show"); 45 | 46 | setTimeout(() => { 47 | notification.classList.remove("show"); 48 | }, 3000); 49 | } -------------------------------------------------------------------------------- /lesson-2/style.css: -------------------------------------------------------------------------------- 1 | .container { 2 | max-width: 800px; 3 | margin: 0 auto; 4 | padding: 20px; 5 | } 6 | 7 | pre { 8 | background-color: #080000; 9 | padding: 10px; 10 | overflow-x: auto; 11 | } 12 | 13 | code { 14 | font-family: "Courier New", monospace; 15 | font-size: 14px; 16 | } 17 | 18 | .python { 19 | color: #e83e8c; 20 | } 21 | 22 | .copy-button { 23 | display: inline-block; 24 | background-color: #4caf50; 25 | color: white; 26 | border: none; 27 | padding: 10px 20px; 28 | font-size: 16px; 29 | cursor: pointer; 30 | transition: background-color 0.3s ease; 31 | } 32 | 33 | .copy-button:hover { 34 | background-color: #45a049; 35 | } 36 | 37 | .notification { 38 | position: fixed; 39 | top: 50%; 40 | left: 50%; 41 | transform: translate(-50%, -50%); 42 | background-color: #f44336; 43 | color: white; 44 | padding: 16px; 45 | border-radius: 5px; 46 | visibility: hidden; 47 | opacity: 0; 48 | transition: visibility 0s, opacity 0.3s ease; 49 | } 50 | 51 | .notification.show { 52 | visibility: visible; 53 | opacity: 1; 54 | } -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", function () { 2 | const screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 3 | const dropdownElement = document.querySelector(".dropdown"); 4 | const navElement = document.querySelector(".hide-on-small-screen ul"); 5 | 6 | if (screenWidth <= 760) { 7 | const menuImgSrc = "images/menu.png"; // Replace with the actual menu image source 8 | const crossImgSrc = "images/cross.png"; // Replace with the actual cross image source 9 | 10 | const imgElement = document.createElement("img"); 11 | imgElement.src = menuImgSrc; 12 | imgElement.alt = "Menu"; 13 | imgElement.style.height = "60px"; 14 | imgElement.style.width = "60px"; 15 | 16 | dropdownElement.appendChild(imgElement); 17 | 18 | dropdownElement.addEventListener("click", function () { 19 | navElement.classList.toggle("nav-hidden"); 20 | navElement.classList.toggle("nav-visible"); 21 | imgElement.src = navElement.classList.contains("nav-visible") ? crossImgSrc : menuImgSrc; 22 | imgElement.alt = navElement.classList.contains("nav-visible") ? "Cross" : "Menu"; 23 | }); 24 | } 25 | }); -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | ::-webkit-scrollbar { 2 | width: 8px; 3 | background-color: #fff; 4 | } 5 | 6 | ::-webkit-scrollbar-track { 7 | background-color: #f2f2f2; 8 | } 9 | 10 | ::-webkit-scrollbar-thumb { 11 | background-image: linear-gradient(to bottom, #ff9d00, #f07b3f, #d63d3d, #b3006e, #6a00a6); 12 | border-radius: 10px; 13 | border: 2px solid #fff; 14 | box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); 15 | } 16 | 17 | ::-webkit-scrollbar-thumb:hover { 18 | background-image: linear-gradient(to bottom, #0b9729, #321990, #d7e420, #13c3f9, #cc7f0b); 19 | } 20 | 21 | .body { 22 | background-color: black; 23 | } 24 | 25 | marquee { 26 | text-shadow: rgb(65, 186, 69) -1px 1px 0px, rgb(198, 61, 43) 1px 1px 0px, rgb(66, 175, 172) 1px -1px 0px, rgb(198, 194, 63) -1px -1px 0px; 27 | color: rgb(18, 18, 18); 28 | letter-spacing: 5px; 29 | background: rgb(18, 18, 18); 30 | font-size: 4em; 31 | padding: 5px; 32 | } 33 | 34 | p { 35 | color: skyblue; 36 | } 37 | 38 | .main-body { 39 | display: flex; 40 | justify-content: space-between; 41 | flex-direction: row; 42 | padding-left: 10px; 43 | padding-right: 10px; 44 | padding-top: 10px; 45 | background-color: coral; 46 | } 47 | 48 | .left { 49 | color: skyblue; 50 | min-width: 300px; 51 | margin-bottom: left; 52 | background-color: black; 53 | height: 100vh; 54 | overflow: auto; 55 | } 56 | 57 | .logo { 58 | font-family: monospace; 59 | text-align: center; 60 | font-size: 30px; 61 | display: flex; 62 | flex-direction: row; 63 | } 64 | 65 | .logo-div { 66 | display: flex; 67 | flex-direction: column; 68 | } 69 | 70 | .logo-img { 71 | margin-top: 13px; 72 | margin-left: 20px; 73 | } 74 | 75 | .code { 76 | font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; 77 | font-size: 25px !important; 78 | font-weight: 700; 79 | color: #00eeff; 80 | position: relative; 81 | margin-top: 30px; 82 | padding-left: 20px; 83 | } 84 | 85 | .explorer { 86 | font-family: cursive; 87 | font-size: 30px !important; 88 | font-weight: 700; 89 | color: crimson; 90 | padding-left: 15px; 91 | } 92 | 93 | hr.one { 94 | overflow: visible; 95 | /* For IE */ 96 | height: 30px; 97 | border-style: solid; 98 | border-color: rgb(25, 204, 70); 99 | border-width: 1px 0 0 0; 100 | border-radius: 20px; 101 | } 102 | 103 | hr.one:before { 104 | display: block; 105 | content: ""; 106 | height: 30px; 107 | margin-top: -31px; 108 | border-style: solid; 109 | border-color: rgb(225, 15, 109); 110 | border-width: 0 0 1px 0; 111 | border-radius: 20px; 112 | } 113 | 114 | hr.two { 115 | border: 0; 116 | height: 1px; 117 | background-image: linear-gradient(to right, #73101000, #e41717bf, #100f0f00); 118 | } 119 | 120 | .contents { 121 | font-family: monospace; 122 | font-size: 40px; 123 | padding-left: 60px; 124 | } 125 | 126 | ul { 127 | padding-left: 10px; 128 | } 129 | 130 | li { 131 | display: flex; 132 | flex-direction: row; 133 | } 134 | 135 | .arrow-img { 136 | max-height: 25px; 137 | max-width: 25px; 138 | } 139 | 140 | a { 141 | text-decoration: none; 142 | } 143 | 144 | .lesson { 145 | font-family: cursive; 146 | display: flex; 147 | justify-content: center; 148 | flex-direction: row; 149 | font-size: 20px; 150 | padding-left: 30px; 151 | color: chartreuse; 152 | } 153 | 154 | .open { 155 | display: none; 156 | } 157 | 158 | /* RIGHT */ 159 | 160 | .right { 161 | background-color: black; 162 | height: 100vh; 163 | overflow: auto; 164 | margin-bottom: 10px; 165 | } 166 | 167 | 168 | .h1 { 169 | text-align: center; 170 | /* text-decoration: underline; */ 171 | font-family: monospace; 172 | font-size: 30px; 173 | color: #00eeff; 174 | } 175 | 176 | /* Set the aspect ratio for the video */ 177 | .video-container { 178 | padding: 20px; 179 | position: relative; 180 | padding-bottom: 56.25%; 181 | /* 16:9 aspect ratio (height / width) */ 182 | height: 0; 183 | overflow: hidden; 184 | } 185 | 186 | /* Make the video responsive */ 187 | .video-container iframe { 188 | position: absolute; 189 | top: 0; 190 | left: 0; 191 | width: 100%; 192 | height: 100%; 193 | } 194 | 195 | /* Apply different styles for smaller screens */ 196 | @media (max-width: 767px) { 197 | .video-container { 198 | padding-bottom: 75%; 199 | /* 4:3 aspect ratio for smaller screens */ 200 | } 201 | } 202 | 203 | /* Apply different styles for larger screens */ 204 | @media (min-width: 1200px) { 205 | .video-container { 206 | padding-bottom: 42.19%; 207 | /* Custom aspect ratio for larger screens */ 208 | } 209 | } 210 | 211 | 212 | #box { 213 | background: rgba(255, 255, 255, 0.23); 214 | border-radius: 16px; 215 | width: fit-content; 216 | box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); 217 | backdrop-filter: blur(5px); 218 | -webkit-backdrop-filter: blur(5px); 219 | border: 1px solid rgba(255, 255, 255, 0.3); 220 | padding: 10px; 221 | font-family: cursive; 222 | color: chartreuse; 223 | font-size: 20px; 224 | cursor: pointer; 225 | margin-top: 10px; 226 | margin-bottom: 10px; 227 | } 228 | 229 | .p { 230 | padding-left: 50px; 231 | padding-right: 50px; 232 | font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; 233 | } 234 | 235 | .story { 236 | font-family: Verdana, Geneva, Tahoma, sans-serif; 237 | font-style: italic; 238 | color: rgb(226, 249, 25); 239 | padding-left: 10px; 240 | } 241 | 242 | /* Default styling for the image */ 243 | 244 | .img { 245 | width: 100%; 246 | height: auto; 247 | } 248 | 249 | /* Media query for screens with a maximum width of 768 pixels */ 250 | @media (max-width: 768px) { 251 | .img { 252 | max-width: 100%; 253 | } 254 | } 255 | 256 | /* Media query for screens with a maximum width of 480 pixels */ 257 | @media (max-width: 480px) { 258 | .img { 259 | max-width: 100%; 260 | } 261 | } 262 | 263 | .div-img { 264 | padding-left: 20px; 265 | padding-right: 20px; 266 | } 267 | 268 | #table { 269 | padding-left: 20px; 270 | padding-right: 20px; 271 | } 272 | 273 | /* Default styling for the table */ 274 | table { 275 | width: 100%; 276 | border-collapse: collapse; 277 | margin-bottom: 5px; 278 | } 279 | 280 | th, 281 | td { 282 | padding: 10px; 283 | text-align: left; 284 | border: 1px solid #ccc; 285 | } 286 | 287 | /* Styling for table header */ 288 | thead th { 289 | background-color: #0a0a0a; 290 | color: #03f90b; 291 | } 292 | 293 | /* Styling for table body */ 294 | tbody td { 295 | background-color: #201a36; 296 | } 297 | 298 | tbody tr { 299 | color: #b3006e; 300 | } 301 | 302 | /* Hover effect for table rows */ 303 | tbody tr:hover { 304 | background-color: #2f2a48; 305 | color: #fff; 306 | } 307 | 308 | /* Responsive table styles */ 309 | @media screen and (max-width: 768px) { 310 | table { 311 | overflow-x: auto; 312 | max-width: 100%; 313 | display: block; 314 | } 315 | 316 | th, 317 | td { 318 | white-space: nowrap; 319 | } 320 | } 321 | 322 | 323 | /* Footer */ 324 | 325 | footer { 326 | background-color: #030340; 327 | padding: 20px; 328 | text-align: center; 329 | color: darkorange; 330 | font-size: 25px; 331 | } 332 | 333 | .footer-code { 334 | color: #03f90b; 335 | } 336 | 337 | /* RESPONSIVE */ 338 | 339 | @media screen and (max-width: 760px) { 340 | 341 | .contents, 342 | .nav-two { 343 | display: none; 344 | } 345 | 346 | .nav-hidden { 347 | display: none; 348 | } 349 | 350 | .nav-visible { 351 | display: block; 352 | } 353 | 354 | .main-body { 355 | flex-direction: column; 356 | } 357 | 358 | .left { 359 | min-width: unset; 360 | width: 100%; 361 | } 362 | 363 | .right { 364 | width: 100%; 365 | } 366 | 367 | .left { 368 | height: auto; 369 | overflow: auto; 370 | } 371 | 372 | .dropdown { 373 | display: flex; 374 | flex-wrap: wrap; 375 | align-items: center; 376 | justify-content: flex-end; 377 | margin-left: auto; 378 | padding-right: 20px; 379 | } 380 | 381 | .p { 382 | padding-left: 20px; 383 | padding-right: 20px; 384 | } 385 | 386 | .open { 387 | display: block; 388 | } 389 | 390 | ::-webkit-scrollbar { 391 | display: none; 392 | } 393 | 394 | ol { 395 | padding-left: 20px; 396 | padding-right: 20px; 397 | } 398 | 399 | .do { 400 | padding-left: 20px !important; 401 | padding-right: 0px !important; 402 | } 403 | 404 | .dos { 405 | padding-left: 20px !important; 406 | padding-right: 0px !important; 407 | } 408 | 409 | .marquee { 410 | display: none; 411 | } 412 | } --------------------------------------------------------------------------------