Data Manipulation with Lists and Dictionaries Flashcards

1
Q

What is a ‘List’ variable type?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an ‘IList’ variable type?

A

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>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between lists and arrays?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The type of collection that doesn’t have a fixed number of elements is known as:
1.Array
2. List
3. String
4. Variable

A
  1. List
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can we loop through to access and retrieve each value from a dictionary collection?

  1. 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

  1. By using a For Each activity and then using the variable values. Our activity could look like this:

For Each: currentItem In DictionaryVariableName.Values

  1. 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

  1. By using a For Each activity and then using the variable keys. Our activity could look like this:

For Each: currentItem In DictionaryVariableName.Keys

A
  1. By using a For Each activity and then using the variable values. Our activity could look like this:

For Each: currentItem In DictionaryVariableName.Values

  1. By using a For Each activity and then using the variable keys. Our activity could look like this:

For Each: currentItem In DictionaryVariableName.Keys

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the correct expression for initializing a dictionary that has ‘Int32’ as key type and ‘List of String’ as value type?

  1. New dictionary (of String, List (of String))
  2. New dictionary (of Int32, new List (of String))
  3. New dictionary (of Int32), new List (of String)
  4. New dictionary (of Int32, List (of String))
A
  1. New dictionary (of Int32, List (of String))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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)

A

1 New Dictionary(of String, Int32)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

1 List

2 Dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which collection type does not have a fixed number of elements?

Choose one answer

1 String

2 Array

3 Int32

4 List

A

LIST

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

  1. To: BirthDates(“Apr/20/1980”) Value: “John Doe”
  2. To: BirthDates(John Doe) Value: “Apr/20/1980”
  3. To: BirthDates(“John Doe”) Value: “Apr/20/1980”
  4. To: “John Doe” Value: “Birth Dates”
A
  1. To: BirthDates(“John Doe”) Value: “Apr/20/1980”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What type must we select to declare a dictionary variable?
Choose one answer

  1. System.Generic as type.
  2. System.Collections.Generic.Dictionary as type.
  3. System.Collections as type.
  4. System.Dictionary as type.
A
  1. System.Collections.Generic.Dictionary as type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

  1. VarName.ContainsKey(Key)
  2. VarName.TryGetValue(Key, Value)
  3. VarName.Item(Key)
  4. VarName.Count
A
  1. VarName.TryGetValue(Key, Value)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can we initialize the following variable type:

List<IList<String>></String>

  1. new IList (of IList(of String))
  2. new List (of String))
  3. new IList (of String))
  4. new List (of IList(of String))
A
  1. new List (of IList(of String))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the ‘String.Join’ method allows us to do?

Choose one answer

  1. Print a list of strings.
  2. Initialize a list of string type elements.
  3. Add a new item to a List of String.
  4. Merge two collections.
A

Print a list of strings - this was given as the answer in UiPath - however String. Join is a concatenation method