Docsity

PrepIQ Beginner Flux Tutorial Ultimate Exam, Exams of Technology

Toggle sidebar
bg1
PrepIQ Beginner Flux Tutorial Ultimate
Exam
**Question 1. Which symbol is used to comment a single line in Flux?**
A) #
B) //
C) <!-- -->
D) /* */
Answer: B
Explanation: In Flux, `//` starts a single-line comment, similar to many C-style
languages.
**Question 2. What does the pipe forward operator `|>` do in a Flux script?**
A) It redirects output to a file.
B) It assigns a variable.
C) It passes the result of the left expression as the first argument to the function
on the right.
D) It creates a new bucket.
Answer: C
Explanation: `|>` chains operations by feeding the left-hand result into the
right-hand function.
**Question 3. Which of the following is the correct way to declare a variable
named `temp` with the integer value 25?**
A) var temp = 25;
B) let temp = 25;
C) const temp = 25;
D) temp := 25;
Answer: A
Explanation: Flux uses the `var` keyword and `=` for variable declaration and
assignment.
**Question 4. Which data type would you use to store the value `true` in Flux?**
A) string
B) int
C) bool
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47

Partial preview of the text

Download PrepIQ Beginner Flux Tutorial Ultimate Exam and more Exams Technology in PDF only on Docsity!

Exam

Question 1. Which symbol is used to comment a single line in Flux? A) # B) // C) D) /* */ Answer: B Explanation: In Flux, // starts a single-line comment, similar to many C-style languages. Question 2. What does the pipe forward operator |&gt; do in a Flux script? A) It redirects output to a file. B) It assigns a variable. C) It passes the result of the left expression as the first argument to the function on the right. D) It creates a new bucket. Answer: C Explanation: |&gt; chains operations by feeding the left-hand result into the right-hand function. Question 3. Which of the following is the correct way to declare a variable named temp with the integer value 25? A) var temp = 25; B) let temp = 25; C) const temp = 25; D) temp := 25; Answer: A Explanation: Flux uses the var keyword and = for variable declaration and assignment. Question 4. Which data type would you use to store the value true in Flux? A) string B) int C) bool

Exam

D) float Answer: C Explanation: bool is the Boolean data type representing true or false. Question 5. How do you represent a duration of 5 minutes in Flux? A) 5m B) 5min C) 5: D) 5minutes Answer: A Explanation: Duration literals use a number followed by a unit, e.g., 5m for five minutes. Question 6. Which of the following is a valid anonymous (lambda) function that adds 10 to its input? A) (r) => r + 10 B) (x) => { return x + 10 } C) (v) => v + 10 D) All of the above Answer: D Explanation: All forms are syntactically correct anonymous functions in Flux. Question 7. In a record (object) literal, how do you access the field named _value? A) r["_value"] B) r._value C) r.value D) Both A and B Answer: D Explanation: Flux allows both dot notation and bracket notation to access record fields. Question 8. Which syntax correctly creates an array containing the numbers 1, 2, and 3?

Exam

Explanation: If stop is omitted, it defaults to now(). Both forms are valid. Question 12. Which of the following strings represents an absolute start time of January 1, 2024 at midnight UTC? A) "2024-01-01T00:00:00Z" B) "2024/01/01 00:00:00" C) "01-01-2024T00:00Z" D) "2024-01-01 00:00:00" Answer: A Explanation: Flux uses ISO-8601 format with a trailing Z for UTC. Question 13. In a filter() call, which column typically stores the measurement name? A) _field B) _measurement C) _value D) _tag Answer: B Explanation: _measurement holds the measurement name for each point. Question 14. Which predicate correctly filters rows where the field _field equals "temperature"? A) (r) => r._field == "temperature" B) (r) => r.field == "temperature" C) (r) => r["_field"] = "temperature" D) (r) => r._field = "temperature" Answer: A Explanation: Equality uses ==; the column name is _field. Question 15. How can you filter for a tag named location with the value "office"? A) (r) => r.location == "office" B) (r) => r["location"] == "office"

Exam

C) (r) => r._tag == "office" D) Both A and B Answer: D Explanation: Tags appear as regular columns, accessible via dot or bracket notation. Question 16. Which function calculates the mean of a numeric column over each group? A) sum() B) mean() C) count() D) max() Answer: B Explanation: mean() returns the arithmetic average of the values. Question 17. What does the group() function without arguments do? A) Removes all grouping, returning a single table. B) Groups by all columns automatically. C) Groups by the _measurement column only. D) Throws an error. Answer: A Explanation: Calling group() with no columns clears existing grouping, producing a single table. Question 18. Which option correctly groups data by the tag device_id? A) group(columns: ["device_id"]) B) group(by: ["device_id"]) C) group(columns: device_id) D) group(tags: ["device_id"]) Answer: A Explanation: group(columns: ["device_id"]) specifies the column(s) to group by.

Exam

D) Both A and C Answer: D Explanation: Both syntaxes are valid; fn: sum is shorthand for the same operation. Question 23. Which function can be used to reshape a table so that each distinct _field becomes its own column? A) pivot() B) reshape() C) transpose() D) unpivot() Answer: A Explanation: pivot() turns rows into columns based on a key, often _field. Question 24. In a pivot() call, what does the rowKey parameter specify? A) Columns that become new rows. B) Columns used to identify each output row (e.g., _time). C) Columns that will be dropped. D) The order of the resulting columns. Answer: B Explanation: rowKey tells Flux which column(s) uniquely identify each row in the output. Question 25. Which statement correctly joins two streams on the _time column? A) join(tables: {a: left, b: right}, on: ["_time"]) B) join(left: left, right: right, on: ["_time"]) C) join(tables: {left, right}, on: "_time") D) join(tables: {a: left, b: right}) Answer: A Explanation: The join() function expects a map of tables and an on array of column names. Question 26. What is the default join method if none is specified?

Exam

A) inner B) outer C) left D) right Answer: A Explanation: join() defaults to an inner join, returning rows present in both tables. Question 27. Which function returns the earliest timestamp in each group? A) earliest() B) first() C) min() D) start() Answer: A Explanation: earliest() returns the first point in time for each group. Question 28. How can you rename a column _value to temperature? A) rename(columns: {"_value": "temperature"}) B) set(column: "temperature", value: r._value) C) map(fn: (r) => ({temperature: r._value})) D) Both A and C Answer: D Explanation: rename() directly changes column names; map() can also produce a new column and drop the old one. Question 29. Which keyword is used to terminate a Flux script and output the final table? A) return B) yield C) output D) finish Answer: B Explanation: yield(name: "result") emits the table as the script’s output.

Exam

Answer: A Explanation: const creates an immutable binding; var would allow reassignment. Question 34. In Flux, what does the int(v: "42") expression do? A) Converts the string "42" to an integer 42. B) Returns the ASCII code of "42". C) Throws a type error. D) Parses "42" as a float. Answer: A Explanation: int(v: string) parses a numeric string into an integer. Question 35. Which function can be used to calculate the cumulative sum of _value over time? A) cumulativeSum() B) sum() C) runningSum() D) accumulate() Answer: A Explanation: cumulativeSum() adds each value to the sum of all previous values. Question 36. What is the effect of the drop(columns: ["_start", "_stop"]) function? A) Removes the specified columns from each table. B) Filters out rows where those columns are null. C) Renames the columns. D) Moves the columns to the end of the table. Answer: A Explanation: drop() discards the listed columns. Question 37. Which built-in function returns the current time as a Flux time value?

Exam

A) now() B) current() C) timestamp() D) time() Answer: A Explanation: now() yields the current UTC time. Question 38. How would you convert a time literal "2024-02-01T12:00:00Z" to a Flux time type? A) time(v: "2024-02-01T12:00:00Z") B) date(v: "2024-02-01T12:00:00Z") C) time("2024-02-01T12:00:00Z") D) timestamp("2024-02-01T12:00:00Z") Answer: A Explanation: time(v: string) parses an ISO-8601 timestamp into a time value. Question 39. Which operator is used to concatenate two strings in Flux? A) + B) & C) ++ D) concat() Answer: A Explanation: The + operator works for both numeric addition and string concatenation. Question 40. What does the exists function test for? A) Whether a column exists in the table. B) Whether a value is non-null. C) Whether a bucket exists. D) Whether a tag key is present. Answer: B Explanation: exists r._value returns true if the field is not null.

Exam

C) Filters rows by field name. D) Renames a field. Answer: A Explanation: schema.fieldKey() produces a table of distinct field keys for a bucket. Question 45. Which function would you use to convert a float value to an integer by truncating the decimal part? A) int(v: float) B) floor(v: float) C) truncate(v: float) D) round(v: float) Answer: A Explanation: int(v: float) casts the float to an integer, discarding the fractional component. Question 46. In a filter() call, how would you keep rows where the _value is greater than 100? A) (r) => r._value > 100 B) (r) => r._value >= 100 C) (r) => r._value < 100 D) (r) => r._value == 100 Answer: A Explanation: The predicate &gt; selects values strictly greater than 100. Question 47. Which statement correctly creates a multi-line comment? A) // This is a comment B) /* This is a comment */ C) D) # This is a comment Answer: B Explanation: /* … */ encloses a block comment spanning multiple lines.

Exam

Question 48. What does the experimental package provide? A) Deprecated functions. B) Functions that are not yet stable, such as experimental.to(). C) Core language syntax. D) None of the above. Answer: B Explanation: The experimental namespace contains functions still under development. Question 49. Which function can be used to write data back to a bucket? A) to() B) write() C) insert() D) push() Answer: A Explanation: to(bucket: "dest") streams the result of a query into another bucket. Question 50. How would you limit the query to return only the first 10 rows? A) limit(n: 10) B) top(n: 10) C) head(n: 10) D) Both A and C Answer: D Explanation: Both limit(n: 10) and head(n: 10) return the first 10 rows; limit is more generic. Question 51. Which function returns the maximum value of _value for each group? A) max() B) highest() C) peak() D) top()

Exam

B) delta() C) derivative() D) diff() Answer: A Explanation: difference() computes the change between consecutive rows. Question 56. What is the result of float(v: "3.5")? A) 3.5 as a float B) 3 as an int C) "3.5" as a string D) Error – cannot convert string to float Answer: A Explanation: float(v: string) parses the string into a floating-point number. Question 57. Which clause can be used to restrict a query to a specific measurement named "cpu"? A) |> filter(fn: (r) => r._measurement == "cpu") B) |> where(_measurement == "cpu") C) |> select(measurement: "cpu") D) |> match(_measurement, "cpu") Answer: A Explanation: filter() with a predicate on _measurement selects the desired measurement. Question 58. Which function returns the number of rows in each group? A) count() B) length() C) size() D) rows() Answer: A Explanation: count() tallies rows per group.

Exam

Question 59. In Flux, what does the fill() function do? A) Replaces null values with a specified value. B) Removes rows containing nulls. C) Fills missing time windows with zeros. D) Both A and C depending on parameters. Answer: D Explanation: fill(value: 0) replaces nulls; fill(usePrevious: true) propagates previous values, useful for time-window gaps. Question 60. Which of the following is a valid way to create a table with a single row containing _time and _value? A) array.from(rows: [{_time: now(), _value: 10}]) B) table.create(rows: [{_time: now(), _value: 10}]) C) from(bucket:"") |> range(start: now()) |> limit(n:1) |> set(_value:10) D) data = {_time: now(), _value: 10} Answer: A Explanation: array.from() builds a table from an array of record literals. Question 61. Which function can be used to compute the rate of change per second for a cumulative counter? A) derivative(unit: 1s) B) rate(unit: 1s) C) diff(unit: 1s) D) change(unit: 1s) Answer: A Explanation: derivative(unit: 1s) calculates the per-second change. Question 62. What does the experimental.greedyJoin() function differ from the regular join()? A) It performs a Cartesian product before applying the join condition. B) It is optimized for large datasets. C) It automatically matches columns with the same name. D) It does not require an on parameter.

Exam

Question 66. What is the effect of the experimental.group() function compared to the standard group()? A) It allows grouping by dynamic expressions. B) It adds support for hierarchical grouping. C) It is identical; only experimental for future changes. D) It automatically drops empty groups. Answer: C Explanation: Currently experimental.group() mirrors the behavior of group() but is marked experimental for possible future enhancements. Question 67. Which of the following correctly casts a string "false" to a boolean? A) bool(v: "false") B) bool("false") C) toBool("false") D) parseBool("false") Answer: A Explanation: bool(v: string) parses "true"/"false" into a Boolean. Question 68. In Flux, which operator is used for exponentiation? A) ^ B) ** C) pow() D) ^ is not supported; use pow() Answer: D Explanation: Flux does not have an exponentiation operator; you must use the math.pow(x, y) function. Question 69. Which function would you use to calculate the median of a numeric column? A) median() B) middle() C) quantile(q: 0.5) D) Both A and C

Exam

Answer: D Explanation: median() is a shortcut for quantile(q: 0.5). Question 70. How can you rename multiple columns at once? A) rename(columns: {"old1":"new1", "old2":"new2"}) B) rename(old1:"new1", old2:"new2") C) rename({"old1":"new1","old2":"new2"}) D) Both A and C Answer: A Explanation: rename() accepts a map of old→new column names. Question 71. Which function can be used to compute the moving average with a window of 5 points? A) movingAverage(n:5) B) movingAverage(every:5) C) movingAverage(period:5) D) movingAverage(window:5) Answer: A Explanation: movingAverage(n: 5) computes the average over the last 5 points. Question 72. What does the experimental.toString() function do? A) Converts any value to its string representation. B) Parses a string into a number. C) Serializes a table to JSON. D) None of the above. Answer: A Explanation: experimental.toString(v: value) returns a string version of the input. Question 73. Which built-in variable provides the start time of the query’s time range? A) v.timeRangeStart