Data Manipulation with Lists and Dictionaries Flashcards
What is a ‘List’ variable type?
The List<T> is a data structure part of the System.Collections.Generic namespace consisting of objects of the same data type. The '<T>' represents the type of elements in the list, for example strings or integers.</T></T>
Each object has a fixed position in the list, and thus it can be accessed by the specific index. Additionally, it provides methods for searching, sorting, and manipulating lists.
What is an ‘IList’ variable type?
The IList is actually an Interface.
It is a collection of objects that can be accessed individually by their specific indexes.
As in the case of List, the ‘<T>' represents the type of elements in the list. The IList<T> generic interface is a descendant of the ICollection<T> generic interface and is the base interface of all generic lists.</T></T></T>
Both List and IList type of variables can be initialized with ‘new list (of…)’. For example, if we have a List of IList of String elements type, looking like ‘List<IList<String>>', we can write the following value in the Default value field to initialize it:</String>
new List (of IList(of String))
The same initialization value applies for the ‘IList<List<String>>' type of variable.</String>
What is the difference between lists and arrays?
Both lists and arrays are collection types of variables.
The array variable enables you to store multiple values of the same type. UiPath Studio supports as many types of arrays as it does types of variables. This means that you can create an array of numbers, one of strings, one of Boolean values and so on.
While arrays are fixed-size structures for storing multiple objects, lists allow us to add, insert, and remove items.
If you want to work with a collection that doesn’t have a fixed number of elements, you can use a list instead of an array.
The type of collection that doesn’t have a fixed number of elements is known as:
1.Array
2. List
3. String
4. Variable
- List
How can we loop through to access and retrieve each value from a dictionary collection?
- By using an Assign activity and then using the variable keys. Our activity could look like this:
Assign to: DictionaryValues the Set value: DictionaryVariableName.Keys
- By using a For Each activity and then using the variable values. Our activity could look like this:
For Each: currentItem In DictionaryVariableName.Values
- By using an Assign activity and then using the variable values. Our activity could look like this:
Assign to: DictionaryValues the Set value: DictionaryVariableName.Values
- By using a For Each activity and then using the variable keys. Our activity could look like this:
For Each: currentItem In DictionaryVariableName.Keys
- By using a For Each activity and then using the variable values. Our activity could look like this:
For Each: currentItem In DictionaryVariableName.Values
- By using a For Each activity and then using the variable keys. Our activity could look like this:
For Each: currentItem In DictionaryVariableName.Keys
What is the correct expression for initializing a dictionary that has ‘Int32’ as key type and ‘List of String’ as value type?
- New dictionary (of String, List (of String))
- New dictionary (of Int32, new List (of String))
- New dictionary (of Int32), new List (of String)
- New dictionary (of Int32, List (of String))
- New dictionary (of Int32, List (of String))
What expression would you use to initialize a dictionary object that pairs names (key) with ages (value)?
1 New Dictionary(of String, Int32)
2 Dictionary (Int32, String)
3 Dictionary (String, Int32)
4 New Dictionary(of Int32, String)
1 New Dictionary(of String, Int32)
What is the best collection data type to store several cake recipes (names and ingredients)?
Choose the two applicable answers
1 List
2 Dictionary
3 Array
4 String
1 List
2 Dictionary
Which collection type does not have a fixed number of elements?
Choose one answer
1 String
2 Array
3 Int32
4 List
LIST
Consider a dictionary variable (BirthDates), of type String, String, that contains name and birth date pairs. They key values are the names.
You want to add a new key / value pair using an ‘Assign’ activity (John Doe, Apr/20/1980).
What expressions would you enter in the ‘To’ and ‘Value’ fields of the ‘Assign’ activity?
Choose one answer
- To: BirthDates(“Apr/20/1980”) Value: “John Doe”
- To: BirthDates(John Doe) Value: “Apr/20/1980”
- To: BirthDates(“John Doe”) Value: “Apr/20/1980”
- To: “John Doe” Value: “Birth Dates”
- To: BirthDates(“John Doe”) Value: “Apr/20/1980”
In the context of List manipulation, what actions are possible?
Choose all applicable answers
Looping through the items.
Sorting the objects.
Merging lists.
Extracting items and converting them to other data types.
Adding and removing items.
Searching for an element.
Looping through the items.
Sorting the objects.
Merging lists.
Extracting items and converting them to other data types.
Adding and removing items.
Searching for an element.
What type must we select to declare a dictionary variable?
Choose one answer
- System.Generic as type.
- System.Collections.Generic.Dictionary as type.
- System.Collections as type.
- System.Dictionary as type.
- System.Collections.Generic.Dictionary as type.
Which method checks if an item with a given key exists in the dictionary variable and returns a Boolean result and the value if found?
Choose one answer
- VarName.ContainsKey(Key)
- VarName.TryGetValue(Key, Value)
- VarName.Item(Key)
- VarName.Count
- VarName.TryGetValue(Key, Value)
How can we initialize the following variable type:
List<IList<String>></String>
- new IList (of IList(of String))
- new List (of String))
- new IList (of String))
- new List (of IList(of String))
- new List (of IList(of String))
Which of the following methods can be used to populate a list of strings type variable with the values John, Paul, George, and Ringo?
Choose the two applicable answers
Set the Default value in the Variables panel to {“John”, “Paul”, “George”, “Ringo”}
Leave the Default value blank and use Add To Collection activities to populate the list.
Set the Default value in the Variables panel to New List(of String) from {“John”, “Paul”, “George”, “Ringo”}
Initialize the variable with New List(of String) and use Build Collection activity to populate the list.
Set the Default value in the Variables panel to New List(of String) from {“John”, “Paul”, “George”, “Ringo”}
Initialize the variable with New List(of String) and use Build Collection activity to populate the list.