Bird
0
0

Which Python code snippet correctly opens a UART serial connection at 9600 baud on Raspberry Pi?

easy📝 Syntax Q12 of 15
Raspberry Pi - Serial UART Communication
Which Python code snippet correctly opens a UART serial connection at 9600 baud on Raspberry Pi?
Aserial.connect('/dev/ttyS0', 9600)
Bserial.open('/dev/ttyS0', 9600)
Cserial.Serial('/dev/ttyS0', 9600)
Dserial.start('/dev/ttyS0', 9600)
Step-by-Step Solution
Solution:
  1. Step 1: Recall Python serial library usage

    The correct method to open a serial port is using serial.Serial() with device and baud rate as arguments.
  2. Step 2: Check each option's method name

    Only serial.Serial() is valid; others like open(), connect(), start() do not exist in pyserial.
  3. Final Answer:

    serial.Serial('/dev/ttyS0', 9600) -> Option C
  4. Quick Check:

    Use serial.Serial() to open UART [OK]
Quick Trick: Use serial.Serial() to open UART port [OK]
Common Mistakes:
MISTAKES
  • Using non-existent methods like open() or connect()
  • Forgetting to specify baud rate
  • Using wrong device path

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes