exam questions

Exam PCAP-31-03 All Questions

View all questions & answers for the PCAP-31-03 exam

Exam PCAP-31-03 topic 1 question 4 discussion

Actual exam question from Python Institute's PCAP-31-03
Question #: 4
Topic #: 1
[All PCAP-31-03 Questions]

Assuming that the code below has been executed successfully, which of the following expressions will always evaluate to True? (Choose two.) import random v1 = random.random() v2 = random.random()

  • A. len(random.sample([1,2,3],1)) > 2
  • B. v1 == v2
  • C. random.choice([1,2,3]) > 0
  • D. v1>1
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

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
narayanan010
Highly Voted 1 year ago
Only option C, `random.choice([1,2,3]) > 0` will return TRUE. All other options are FALSE.
upvoted 6 times
...
Sharif24
Most Recent 9 months, 1 week ago
Selected Answer: C
import random v1 = random.random() v2 = random.random() print(v1 ==v2) #False print(v1>1) # False print(random.choice(([1,2,3],1))>0) # True
upvoted 1 times
...
DKAT2023
11 months, 1 week ago
C is the correct
upvoted 1 times
...
Nikhil_Durgesh
1 year ago
Option C is correct Explanation: import random v1 = random.random() v2 = random.random() random.choice([1,2,3]) > 0` will return TRUE. All others options will return output as FALSE.
upvoted 3 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 ...