Scripts and sequences
About this video
Computers were first built to automate complex, repetitive calculations, and today small single-purpose programs called scripts automate everyday tasks. Scripts need data to work on, and data with a meaningful order is called a sequence. In Python, strings and lists are the two fundamental sequences, and a list is our first data structure for organizing data.
You'll be able to
- explain what a script is and how it differs from an app or game.
- explain what a sequence is and name Python's two fundamental sequence types.
- describe what a data structure does.
Key words
- script
- A small single-purpose program you run on demand to perform a specific task.
- sequence
- Data that has a meaningful ordering, like the words of an article.
- list
- A Python data structure that stores many values in order.
- data structure
- A way of organizing data so a program can store and access it efficiently.
Transcript
- [Instructor] How can programs make our lives easier? While technology exists in almost everything nowadays, the first computers were built to automate complex, repetitive, and time-consuming calculations. They were used to calculate trajectories for spacecraft, analyze huge amounts of census data, and decode encrypted communications during war time.
Now, there's nothing special to these calculations per se. I could manually solve some version of these equations to calculate the trajectory myself. In fact, all of these calculations used to be performed by teams of humans. But with the sheer complexity and amount of data to process, these tasks take humans a lot of time.
Computers, on the other hand, can process huge amounts of data in milliseconds. Modern computers automate tasks beyond just mathematical calculations. They can count the words in an essay, generate captions for a video, or clean up old photos. We often call these types of programs scripts.
A script is a small single-purpose program that we run on demand to perform a specific task. For example, every time I finish a video, I might run a script to generate captions for it. A script differs from an app or game in that those tend to be more complex and long running.
They're not just triggered once to get a result. The logic in a script just comes from functions, loops, and conditionals. The only thing we're missing is a better way to store and organize large amounts of data, because our script needs data to operate on. That data could be an article, it could be a table from a spreadsheet, or it could be a series of readings from a device.
We call data that has a meaningful ordering a sequence. So, for example, the letters and words of an article need to be in that specified order. If I jumble them all up, I don't have the same article. In Python, our two fundamental types of sequences are strings and lists.
A list is a type of data structure. Data structures allow us to organize and access data efficiently. Like functions organize our code, data structures organize our data. So what tedious digital tasks clutter up your everyday life? Think about the data that that task operates on.
With the power of our first data structure, lists, you might just be able to automate that task for good by writing a script.
Video © Khan Academy, used under CC BY-NC-SA. Watch on Khan Academy. Puzzicle is not affiliated with Khan Academy.