Lists: Python's arrays
Until now each variable stored a single value. When you need to store many (10 marks, 1000 numbers), creating a variable for each…
Explore lists in Python, an essential concept in programming that allows you to work with structured sets of data. You will learn how to manipulate and use lists to solve a variety of problems and tasks in programming. This lesson equips you with the necessary skills to work with lists and solve complex programming problems in Python. Enhance your programming skills through practical exercises and expand your abilities in managing structured data.
Until now each variable stored a single value. When you need to store many (10 marks, 1000 numbers), creating a variable for each…
Lists can grow and shrink while the program runs. These are the methods you will use most.
Almost all list exercises follow the same scheme: read values into a list, go through it and show the result.
Once the data is stored, the usual thing is to ask questions about it.
A list can contain other lists. With that you represent tables, boards and drawings: each inner list is a row.
Sorting a list is one of the most studied operations in programming. Python does it for you with sort() and sorted() , but…
The last exercise of the lesson, Mathematical statistics , brings everything together: a list that grows, a menu that repeats…
Slices list[start:stop:step] can be used with negative indexes, steps and omitted limits, both to read and to assign or delete…
Assigning a list to another variable does not copy it : both variables point to the same object, and changing one changes the…
Create a Python program that asks the user for 5 integers, stores them in a list and displays them in reverse order.
Create a Python program to search for values in a list of integers. Follow these steps:
Write a Python program that asks the user for 10 integers. Then, store these numbers in a list and display only the even numbers.
Write a Python program that prompts the user to enter 10 real numbers and displays the arithmetic mean of positive and negative…
Create a Python program that emulates the Unix banner command. Internally, use a list of strings (a table of characters) to store…
Create a Python program that prompts the user for 10 integers and sorts them using the bubble sort algorithm.
Create a Python program that asks the user for the scores of 10 students, divided into 2 groups of 5 students each. Store the…
Create a Python program that builds a two-dimensional list of characters with 20 rows and 70 columns, fills it with the letter X…
Create a Python program that generates mathematical statistics. The program stores up to 1000 decimal numbers in a list and shows…
Create a Python program that generates the drawing of a circle on the screen, dividing it into 360 equidistant points. Use the…
Rotating a list k positions to the right means the last k elements move to the front. Slicing lets you do it without loops.
Turning a list into a set removes repeats but loses the order . To keep it you must remember which items have already been seen.
If two lists are already sorted, they can be merged into a single sorted one by walking through both with two indexes, without…
sort accepts a key function that returns a tuple : it sorts by the first element and, on a tie, by the second, and so on. To…