In Python, the equivalent data structure to array in other languages such as Java is called list. Learn how to create Python lists and change their content.
- [Instructor] In this video, I'm going to give you a quick review of Python List. You may be already familiar with the concept of array in other languages such as Java but in Python the equivalent type that's most commonly used is called List. Just like an array, a list is basically a collection of elements whatever their types might be. They could be numbers, strings, or we could even have a list of lists in Python. An array or Python list is one of the most commonly used types so it's important to know how to use it for recording interviews.
Now to initialize a list, you can write a equals item one, item two, and item three with square brackets and this initializes a list named a with the three strings. To retrieve an element from this list, you can write a square brackets zero which retrieves the first element, item one and a square brackets one retrieves a second element, item two. So Python lists is zero index or the indices in a Python list start at zero.
To change an element in this list, you can write a square brackets one equals new item name and this sets the second element or the element at index one to be new item name. If you print the element at the index one with print a square brackets one then it will print out the new element which is new item name. In a Python list, you could even mix types, for example, with numbers and a string. To find the length of a list, you can call the len function with the list as the input.
So if there are three items in a list a, len of a would return three.
Follow YK Sugishita as he explains what to keep in mind as you prepare for coding interviews. YK covers useful concepts that can help you master your interview, followed by practice problems that test what you know. YK reviews key concepts such as two-dimensional arrays, time complexity, Big-O notation, and hash tables. To wrap up, he shares a few tips for acing your interview, such as how to come up with an optimal solution. Even if you're not prepping for an upcoming job interview, tackling the coding problems covered in this course is a great way to sharpen your programming skills.
- Honing your problem-solving skills
- Preparing for a coding interview
- Using Jupyter Notebook for sample problems in Python
- Using arrays to solve interview problems
- Working with and comparing strings
- Using two-dimensional arrays
- Learning the importance of time complexity in code
- Using Big-O notation to describe the time complexity of code
- Using hash tables and Python dictionaries in Python
- Asking clarifying questions during your interview
- Finding the most efficient solutions to problems
- Testing your proposed code solutions