Bird
0
0

Which of the following is the correct way to set a baud rate of 9600 and a timeout of 1 second using Python's serial library on Raspberry Pi?

easy📝 Syntax Q12 of 15
Raspberry Pi - Serial UART Communication
Which of the following is the correct way to set a baud rate of 9600 and a timeout of 1 second using Python's serial library on Raspberry Pi?
Aserial.Serial('/dev/ttyUSB0', speed=9600, wait=1)
Bserial.Serial('/dev/ttyUSB0', baud=9600, timeout=1)
Cserial.Serial('/dev/ttyUSB0', baudrate=9600, timeout=1)
Dserial.Serial('/dev/ttyUSB0', rate=9600, delay=1)
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct parameter names in serial.Serial()

    The correct parameters are 'baudrate' for speed and 'timeout' for wait time.
  2. Step 2: Match parameters with options

    Only serial.Serial('/dev/ttyUSB0', baudrate=9600, timeout=1) uses 'baudrate=9600' and 'timeout=1' correctly.
  3. Final Answer:

    serial.Serial('/dev/ttyUSB0', baudrate=9600, timeout=1) -> Option C
  4. Quick Check:

    baudrate and timeout are correct parameters [OK]
Quick Trick: Use 'baudrate' and 'timeout' keywords exactly [OK]
Common Mistakes:
MISTAKES
  • Using wrong parameter names like 'speed' or 'rate'
  • Confusing timeout with delay
  • Missing required parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes