Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 72 discussion

Actual exam question from Python Institute's PCAP
Question #: 72
Topic #: 1
[All PCAP Questions]

You are going to read 16 bytes from a binary file into a bytearray called data. Which lines would you use? (Choose two.)

  • A. data = bytearray (16) bf.readinto (data)
  • B. data = binfile.read (bytearray (16))
  • C. bf. readinto (data = bytearray (16))
  • D. data = bytearray (binfile.read (16))
Show Suggested Answer Hide Answer
Suggested Answer: AD 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Ram5678
2 years, 1 month ago
Selected Answer: AD
A and D are correct
upvoted 1 times
...
Jnanada
2 years, 3 months ago
Correct answers are A & D
upvoted 1 times
...
stuartz
2 years, 5 months ago
Selected Answer: AD
A. is a typo and should be two lines because both B & C will cause error.
upvoted 1 times
...
macxsz
2 years, 7 months ago
Selected Answer: AD
A. data = bytearray (16) bf.readinto (data) D. data = bytearray (binfile.read (16))
upvoted 4 times
...
rocky48
2 years, 8 months ago
Selected Answer: AD
A & D are the correct answers.
upvoted 2 times
...
TheNetworkStudent
2 years, 8 months ago
Selected Answer: AD
When all are tested, B & C error. A & D are correct.
upvoted 3 times
...
wts28
2 years, 9 months ago
A & D are the correct answers.
upvoted 1 times
...
sadako11
2 years, 9 months ago
readinto(b) Read up to len(b) bytes into b, and return the number of bytes read. The object b should be a pre-allocated, writable array of bytes, either bytearray or memoryview. I think answer A should be two separate lines: data = bytearray (16) => 16 bytes bytearray named 'data' bf.readinto (data) => read 16 bytes (the length of the byte array) into the bytearray named 'data' D: data = bytearray (binfile.read (16)) =>reading 16 bytes form the binary file and putting it in a bytearray called 'data' A,D are the right answers
upvoted 1 times
...
dougie_fr3sh
2 years, 11 months ago
Confirmed, A & D.
upvoted 1 times
karans
2 years, 10 months ago
How is it A & D?can you please elaborate on it.
upvoted 1 times
...
...
luckymuki
3 years, 1 month ago
It is A,D
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...