1/21
These flashcards cover key programming concepts including variables, data types, data structures, and important functions.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Variable
A named location used to store data in a program. It allows programmers to reuse and update values throughout the code. For example, x = 10 stores the value 10 in a variable.
Data types
Different kinds of data used in programming, such as integers, strings, and Booleans. For example, 5 is an integer, "hello" is a string, and True is a Boolean.
String
A sequence of characters enclosed in quotes, used to store text data. For example, "Yasmine" is a string.
Integer
A whole number without decimals, used for counting and numeric calculations. For example, 10 is an integer.
Boolean
A data type that can only be true or false, used to represent conditions in programming. For example, 3 < 5 evaluates to True.
Type conversion
Changing data from one type to another, often to ensure compatible types for operations. For example, converting "5" to 5 allows mathematical calculations.
List
An ordered collection of items stored in a single variable. It is used to store multiple values together. For example, [1, 2, 3] is a list of numbers.
Indexing
Accessing elements in a list using their position. It allows retrieval of specific items. For example, list[0] returns the first element.
Slicing
Extracting a portion of a list or string by accessing a range of elements. For example, list[1:3] returns elements from index 1 to 2.
Dictionary
A data structure that stores data as key-value pairs. It allows data to be accessed using keys instead of positions. For example, {"name": "Yasmine"} stores a labeled value.
Key-value pair
A key-value pair consists of a key linked to a value. It is used in dictionaries to organize data. For example, "age": 20 connects a key to its value.
Mutable data
Data that can be changed after creation, such as lists. You can modify a list.
Immutable data
Data that cannot be changed after creation, such as strings.
Updating a variable
A variable is updated by assigning it a new value. This replaces the old value stored in it. For example, x = x + 1 increases the value of x.
Storing data
Saving values for later use. For example, saving a number
Computing data
Performing operations on data. For example, calculating the values for its sum
Data structures
Organize and store data efficiently to make access and manipulation easier. For example, lists and dictionaries help manage collections of data.
Difference between a list and dictionary
A list stores data in an ordered sequence, while a dictionary stores data as key-value pairs.Lists use indexing, while dictionaries use keys. For example, lists use positions, dictionaries use labels.
len() function
The len() function returns the number of items in a collection. It is used to measure the size of data structures. For example, len([1,2,3]) returns 3.
sum() function
The sum() function adds all numeric elements in a collection. It is used for quick calculations. For example, sum([1,2,3]) returns 6.
sort() function
The sort() function arranges elements in a list in order. It is used to organize data. For example, [3,1,2].sort() changes the list to [1,2,3].
Importance of data structures
Allow efficient data storage and access, making programs more organized and scalable. For example, using lists or dictionaries improves performance and readability.