Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute Exam PCAP-31-03 Topic 3 Question 85 Discussion

Actual exam question for Python Institute's PCAP-31-03 exam
Question #: 85
Topic #: 3
[All PCAP-31-03 Questions]

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

import random

v1 = random. random()

v2 = random. random()

Show Suggested Answer Hide Answer
Suggested Answer: C, D

Contribute your Thoughts:

Tammara
7 days ago
I'm feeling lucky with option C! Random.choice() will always return one of the values in the list, and they're all greater than or equal to 1, so this should be a guaranteed winner.
upvoted 0 times
...
Luis
8 days ago
Hmm, option B? The random.random() function generates a random float between 0 and 1, so the chance of v1 being equal to v2 is pretty slim. Gotta go with the odds on this one.
upvoted 0 times
...
Gearldine
18 days ago
I'm not sure about B) v1 == v2, because v1 and v2 are random numbers and may or may not be equal.
upvoted 0 times
...
Jeannetta
19 days ago
I agree with Stanton, because the length of a sample of 2 elements from [1,2,3] will always be greater than 2.
upvoted 0 times
...
Stanton
23 days ago
I think A) len(random.sample([1,2,3],2)) > 2 will always evaluate to True.
upvoted 0 times
...
Amalia
27 days ago
I believe option C is also True, as it checks for the existence of a method 'get' in object B.
upvoted 0 times
...
Emeline
28 days ago
I'm not sure about option D, but I think option B is also True.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77