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:

Lennie
25 days ago
Wait, are we supposed to be picking the answers or making funny comments? I'm torn between cracking jokes about the random module and actually trying to solve this problem. Decisions, decisions...
upvoted 0 times
...
Graciela
27 days ago
Option D is tempting, but I don't think it's a safe bet. The random.random() function can return any value between 0 and 1, so there's no guarantee that v1 will always be greater than or equal to 1. Gotta think this through carefully.
upvoted 0 times
Rolande
20 hours ago
A) len(random.sample([1,2,3],2)) > 2
upvoted 0 times
...
...
Nieves
29 days ago
Haha, option A is a bit of a trap, isn't it? You'd think selecting two random numbers from a list of three would always be less than 2, but I guess the random module has a few surprises up its sleeve.
upvoted 0 times
...
Tammara
1 months 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
Shayne
9 days ago
User2: I'm not so sure about that. I'm leaning towards option B because v1 and v2 are generated randomly, so they could be equal.
upvoted 0 times
...
Blythe
19 days ago
User1: I think option A is also a safe bet. If we sample 2 elements from a list of 3, the length will always be greater than 2.
upvoted 0 times
...
...
Luis
1 months 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
Altha
16 days ago
User 2: A) len(random.sample([1,2,3],2)) > 2
upvoted 0 times
...
Sharen
19 days ago
User 1: B) v1 == v2
upvoted 0 times
...
...
Gearldine
2 months 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
2 months 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
2 months ago
I think A) len(random.sample([1,2,3],2)) > 2 will always evaluate to True.
upvoted 0 times
...
Amalia
2 months 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
2 months ago
I'm not sure about option D, but I think option B is also True.
upvoted 0 times
...

Save Cancel