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
1 months 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
1 months 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
Kara
3 days ago
C) random.choice([1,2,3]) >=1
upvoted 0 times
...
Emmanuel
4 days ago
B) v1 == v2
upvoted 0 times
...
Rolande
16 days ago
A) len(random.sample([1,2,3],2)) > 2
upvoted 0 times
...
...
Nieves
1 months 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
2 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
Jestine
9 days ago
User1: Hmm, I see your point. It's a tough choice between B and C then.
upvoted 0 times
...
Jaime
13 days ago
User3: I agree with User2, option B seems like a strong contender. Random numbers can definitely be equal.
upvoted 0 times
...
Shayne
24 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
1 months 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
2 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
1 months ago
User 2: A) len(random.sample([1,2,3],2)) > 2
upvoted 0 times
...
Sharen
1 months 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
3 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
3 months 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