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 128 discussion

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

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

  • A. v1 == v2
  • B. v1 < 1
  • C. random.choice([1,2,3]) > 0
  • D. len(random.sample([1,2,3],1)) > 2
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
macxsz
Highly Voted 2 years, 6 months ago
Selected Answer: BC
B. v1 < 1 C. random.choice([1,2,3]) > 0
upvoted 5 times
...
DezzoPalYeah
Most Recent 1 year, 1 month ago
random.random() returns a float that is greater than 0 but less than 1. v1 = random.random() v1 will always be less than 1 So B is True random.choice([1,2,3]) returns 1,2, or 3. which is always greater than 0. C is True
upvoted 3 times
...
dicksonpwc
1 year, 7 months ago
Ans A, as v1 = 0.054095873573811515, v2 = 0.8975891098469417. So v1 != v2. Then, return False Ans B, v1 =0.054095873573811515. so v1< 1. Then, return True Ans C, random.choice([1,2,3]) = 1. So 1 >0. Then, return True Ans D, len(random.sample([1,2,3],1)) = 1. So 1 < 2. Then, return False Correct Answer should be B and C
upvoted 1 times
...
stuartz
2 years, 5 months ago
B & C >>> import random >>> v1 = random.random() >>> v2 = random.random() >>> print(v1) 0.17779831894224019 >>> print(random.choice([1,2,3])) 1 v1 will always be less than 1 random choice will always be one in the list and greater than 0
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 ...