×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

RxPY MCQs (Multiple-Choice Questions)

RxPY, also known as ReactiveX for Python, is a library for composing asynchronous and event-based programs using observable collections and operators. It provides tools such as Observables, Observers, Subjects, operators, and schedulers for building reactive applications.

RxPY MCQs

These RxPY MCQs cover important concepts such as Observables, Observers, Subjects, operators, subscriptions, schedulers, error handling, and combining observable sequences.

RxPY MCQs and Answers with Explanation

List of RxPY MCQs

The following RxPY multiple-choice questions are designed to test your knowledge of ReactiveX programming in Python.

1. What is RxPY?

  1. A Python library for reactive programming
  2. A Python web framework
  3. A machine learning library
  4. A database management system

Answer: A) A Python library for reactive programming

Explanation:

RxPY is ReactiveX for Python, a library for composing asynchronous and event-based programs using observable collections and operators.

2. What is the main abstraction used to represent a sequence of emitted values in RxPY?

  1. Observer
  2. Observable
  3. Scheduler
  4. Subject

Answer: B) Observable

Explanation:

An Observable represents a push-based sequence that emits values and notifications to its subscribers.

3. Which package is used by current versions of RxPY?

  1. reactivex
  2. rxpython
  3. rxcore
  4. pyreactive

Answer: A) reactivex

Explanation:

Current RxPY documentation uses the reactivex package for creating Observables, operators, Subjects, and schedulers.

4. Which statement correctly describes an Observable?

  1. It only stores static values
  2. It pushes emitted items to observers
  3. It is used only for database queries
  4. It can never signal errors

Answer: B) It pushes emitted items to observers

Explanation:

An Observable produces notifications that can be received by subscribers through callbacks such as on_next, on_error, and on_completed.

5. Which method is used to subscribe to an Observable?

  1. listen()
  2. observe()
  3. subscribe()
  4. attach()

Answer: C) subscribe()

Explanation:

The subscribe() method attaches an observer or callbacks to an Observable and returns a disposable representing the subscription.

6. Which callback receives each value emitted by an Observable?

  1. on_next
  2. on_value
  3. on_emit
  4. on_data

Answer: A) on_next

Explanation:

The on_next callback is invoked whenever an Observable emits an item.

7. Which callback is invoked when an Observable completes normally?

  1. on_finish
  2. on_completed
  3. on_done
  4. on_close

Answer: B) on_completed

Explanation:

The on_completed callback indicates that an Observable has completed its sequence normally.

8. Which callback is used when an Observable terminates because of an error?

  1. on_exception
  2. on_fail
  3. on_error
  4. on_fault

Answer: C) on_error

Explanation:

The on_error callback receives an exception when an Observable terminates with an error.

9. Which function creates an Observable from an iterable?

  1. from_iterable()
  2. iterable()
  3. from_sequence()
  4. to_observable()

Answer: A) from_iterable()

Explanation:

The from_iterable() factory creates an Observable that emits the items from an iterable.

10. Which RxPY factory creates an Observable from one or more specified values?

  1. just()
  2. values()
  3. emit()
  4. single()

Answer: A) just()

Explanation:

The just() factory creates an Observable that emits the specified object or objects.

11. Which factory creates an Observable that emits sequential integers within a specified range?

  1. sequence()
  2. range()
  3. numbers()
  4. count_range()

Answer: B) range()

Explanation:

The range() factory creates an Observable that emits a sequence of sequential integers.

12. Which factory creates an Observable that emits values at regular time intervals?

  1. timer_range()
  2. interval()
  3. periodic()
  4. repeat_interval()

Answer: B) interval()

Explanation:

The interval() factory creates an Observable that emits sequential integers separated by a specified time interval.

13. Which operator transforms each item emitted by an Observable?

  1. map
  2. filter
  3. take
  4. merge

Answer: A) map

Explanation:

The map operator applies a function to each item emitted by the source Observable and produces a new Observable.

14. Which operator selects only items that satisfy a specified condition?

  1. map
  2. filter
  3. reduce
  4. scan

Answer: B) filter

Explanation:

The filter operator emits only those items for which the supplied predicate returns true.

15. Which operator limits the number of items emitted by an Observable?

  1. limit
  2. take
  3. first_n
  4. restrict

Answer: B) take

Explanation:

The take operator emits a specified number of items from the source Observable and then completes.

16. What does the flat_map operator do?

  1. Only filters values
  2. Maps items to Observables and merges the resulting sequences
  3. Stops an Observable immediately
  4. Sorts emitted values

Answer: B) Maps items to Observables and merges the resulting sequences

Explanation:

The flat_map operator projects each source item into an Observable and merges the resulting Observables into a single sequence.

17. Which operator combines multiple Observables by subscribing to them and merging their emissions?

  1. merge
  2. zip
  3. concat_map
  4. join_latest

Answer: A) merge

Explanation:

The merge operator combines multiple Observable sequences into one Observable, allowing their emissions to be interleaved.

18. Which operator emits the values of one Observable followed by another?

  1. merge
  2. concat
  3. zip
  4. combine_latest

Answer: B) concat

Explanation:

The concat operator emits the items from Observables sequentially, waiting for one sequence to complete before subscribing to the next.

19. Which operator combines corresponding values from multiple Observables into tuples?

  1. zip
  2. merge
  3. concat
  4. buffer

Answer: A) zip

Explanation:

The zip operator combines items from multiple Observables according to their corresponding positions.

20. Which operator combines the latest values from multiple Observables whenever one of them emits?

  1. zip
  2. concat
  3. combine_latest
  4. merge_all

Answer: C) combine_latest

Explanation:

The combine_latest operator combines the latest values from multiple source Observables and emits a new result whenever a source emits after all sources have produced a value.

21. Which operator delays emissions until there has been no new item for a specified period?

  1. debounce
  2. delay_subscription
  3. timeout
  4. sample

Answer: A) debounce

Explanation:

The debounce operator suppresses items that are followed by another item within the specified time span and emits when the source remains quiet for that period.

22. Which operator ignores source items after a specified condition becomes false?

  1. skip_while
  2. take_while
  3. filter
  4. take_until

Answer: B) take_while

Explanation:

The take_while operator emits items while a specified condition remains true and stops when the condition becomes false.

23. Which operator skips items while a specified condition remains true?

  1. take_while
  2. skip_while
  3. filter
  4. skip

Answer: B) skip_while

Explanation:

The skip_while operator discards source items while the supplied condition is true and then allows subsequent items through.

24. Which operator counts the number of items emitted by an Observable?

  1. length
  2. count
  3. size
  4. items_count

Answer: B) count

Explanation:

The count operator counts the items emitted by the source Observable and emits the resulting count.

25. Which operator calculates the sum of numeric values emitted by an Observable?

  1. total
  2. add
  3. sum
  4. aggregate_sum

Answer: C) sum

Explanation:

The sum operator calculates the sum of numeric items emitted by an Observable.

26. Which operator applies an accumulator function and emits the final accumulated value?

  1. scan
  2. reduce
  3. aggregate
  4. fold

Answer: B) reduce

Explanation:

The reduce operator applies an accumulator function to the items in sequence and emits the final accumulated result.

27. Which operator emits accumulated intermediate results for each source item?

  1. reduce
  2. scan
  3. sum
  4. aggregate

Answer: B) scan

Explanation:

The scan operator applies an accumulator function and emits each intermediate accumulated result.

28. What is a Subject in RxPY?

  1. An object that is both an Observable and an Observer
  2. A scheduler only
  3. A filtering operator
  4. A type of exception

Answer: A) An object that is both an Observable and an Observer

Explanation:

A Subject can receive notifications and broadcast them to its subscribed observers.

29. Which method sends a value to observers subscribed to a Subject?

  1. emit()
  2. next()
  3. on_next()
  4. send()

Answer: C) on_next()

Explanation:

The on_next() method of a Subject sends a value to all currently subscribed observers.

30. Which Subject stores the latest value and sends it to a new subscriber?

  1. ReplaySubject
  2. BehaviorSubject
  3. AsyncSubject
  4. PublishSubject

Answer: B) BehaviorSubject

Explanation:

A BehaviorSubject stores a current value and emits that value to a new subscriber.

31. Which Subject can replay previously emitted values to new subscribers?

  1. BehaviorSubject
  2. ReplaySubject
  3. AsyncSubject
  4. SingleSubject

Answer: B) ReplaySubject

Explanation:

A ReplaySubject can replay previously emitted notifications to new subscribers, depending on its configured buffering behavior.

32. Which method signals that a Subject has completed?

  1. complete()
  2. finish()
  3. on_completed()
  4. close()

Answer: C) on_completed()

Explanation:

The on_completed() method notifies subscribers that the Subject has completed its sequence.

33. What does the dispose() method of a subscription do?

  1. Creates a new Observable
  2. Unsubscribes and releases subscription resources
  3. Transforms emitted values
  4. Restarts an Observable

Answer: B) Unsubscribes and releases subscription resources

Explanation:

The disposable returned by subscribe() can be disposed to unsubscribe the observer and release associated resources.

34. Which method is used to compose multiple operators in RxPY?

  1. chain()
  2. pipe()
  3. compose_only()
  4. operators()

Answer: B) pipe()

Explanation:

The pipe() method composes multiple operators and applies them from left to right to an Observable.

35. Which syntax correctly imports RxPY operators in the current package?

  1. import rx.ops as op
  2. from reactivex import operators as op
  3. import reactivex.operator as op
  4. from rxpy import operator

Answer: B) from reactivex import operators as op

Explanation:

Current RxPY documentation commonly uses from reactivex import operators as op to access pipe-based operators.

36. Which scheduler is designed to provide a pool of reusable worker threads?

  1. ImmediateScheduler
  2. ThreadPoolScheduler
  3. CurrentThreadScheduler
  4. VirtualTimeScheduler

Answer: B) ThreadPoolScheduler

Explanation:

ThreadPoolScheduler provides a pool of worker threads and can be used for scheduling asynchronous work.

37. What is the purpose of a Scheduler in RxPY?

  1. To store Observable values permanently
  2. To control where and when work is executed
  3. To define Python classes
  4. To convert Observables into lists

Answer: B) To control where and when work is executed

Explanation:

Schedulers provide a mechanism for controlling the execution context and timing of work performed by Observable operations.

38. Which operator specifies the scheduler on which an Observable is subscribed?

  1. observe_on
  2. subscribe_on
  3. schedule_on
  4. run_on

Answer: B) subscribe_on

Explanation:

The subscribe_on operator specifies the scheduler used for subscribing to the source Observable.

39. Which operator specifies the scheduler on which observer notifications are delivered?

  1. subscribe_on
  2. observe_on
  3. notify_on
  4. callback_on

Answer: B) observe_on

Explanation:

The observe_on operator changes the scheduler on which downstream observer callbacks receive notifications.

40. Which operator can replace an error-producing Observable with another Observable sequence?

  1. catch
  2. replace_error
  3. recover
  4. handle_exception

Answer: A) catch

Explanation:

The catch operator can continue an Observable sequence with another Observable when an error occurs.

41. Which operator retries a source Observable when an error occurs?

  1. retry
  2. repeat_error
  3. restart
  4. recover

Answer: A) retry

Explanation:

The retry operator resubscribes to the source when an error occurs, according to its configured retry behavior.

42. Which operator emits a default value when the source Observable completes without emitting an item?

  1. default_if_empty
  2. empty_default
  3. fallback
  4. default_value

Answer: A) default_if_empty

Explanation:

The default_if_empty operator emits a specified default value when the source Observable produces no items.

43. Which operator checks whether all emitted items satisfy a condition?

  1. all
  2. every_item
  3. check_all
  4. validate

Answer: A) all

Explanation:

The all operator determines whether all items emitted by an Observable satisfy a specified predicate.

44. Which operator determines whether an Observable emits a particular value?

  1. find
  2. contains
  3. has_value
  4. exists

Answer: B) contains

Explanation:

The contains operator determines whether a particular item is emitted by the Observable.

45. Which operator can transform an Observable into a shared connectable Observable?

  1. publish
  2. share_only
  3. multicast_only
  4. broadcast

Answer: A) publish

Explanation:

The publish operator converts an ordinary Observable into a connectable Observable that can share emissions among subscribers.

46. Which operator makes a Connectable Observable behave like an ordinary Observable by managing subscriptions?

  1. ref_count
  2. connect_auto
  3. share_count
  4. auto_subscribe

Answer: A) ref_count

Explanation:

The ref_count operator manages connections to a Connectable Observable based on the number of active subscribers.

47. Which operator attaches a timestamp to each emitted item?

  1. time_stamp
  2. timestamp
  3. mark_time
  4. add_time

Answer: B) timestamp

Explanation:

The timestamp operator attaches timing information to each item emitted by the Observable.

48. Which operator measures the time interval between emitted items?

  1. time_interval
  2. interval_time
  3. measure_time
  4. elapsed

Answer: A) time_interval

Explanation:

The time_interval operator converts an Observable into one that indicates the elapsed time between consecutive emissions.

49. Which operator raises an error if a specified period passes without an item being emitted?

  1. timeout
  2. delay_error
  3. time_limit
  4. wait_error

Answer: A) timeout

Explanation:

The timeout operator monitors the source Observable and issues an error notification if the specified period passes without the expected emission.

50. Which statement about RxPY operator chaining is correct?

  1. Operators can only be used individually
  2. RxPY supports pipe-based operator composition and fluent method chaining
  3. Operators cannot create new Observables
  4. Only scheduler methods can be chained

Answer: B) RxPY supports pipe-based operator composition and fluent method chaining

Explanation:

Current RxPY supports both functional pipe-based syntax using pipe() and fluent method chaining directly on an Observable.

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2026 www.includehelp.com. All rights reserved.