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

Actual exam question from Python Institute's PCAP
Question #: 74
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 >= 1
  • B. v1 == v2
  • C. len(random.sample([1,2,3],2)) > 2
  • D. random.choice([1,2,3]) >=1
Show Suggested Answer Hide Answer
Suggested Answer: BD 🗳️

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, 7 months ago
Selected Answer: BD
B. v1 == v2 D. random.choice([1,2,3]) >=1
upvoted 5 times
...
aferiver
Most Recent 1 year, 7 months ago
Selected Answer: AD
It's A and D. random.seed (1) generates always the same secuence of random numbers. random.random() withouth setting the seed value always generates a different number everytime you run the program.
upvoted 2 times
...
Jnanada
2 years, 3 months ago
The correct answers are B and D
upvoted 1 times
...
palagus
2 years, 6 months ago
Selected Answer: BD
The correct answers are B and D. A is not correct because pseudorandom numbers are always between 0 and 1.
upvoted 4 times
...
Norasit
2 years, 7 months ago
B and D random.random() always return value between 0 and 1.
upvoted 1 times
...
rocky48
2 years, 8 months ago
>>> import random >>> random.seed(1) >>> v1=random.random() >>> random.seed(1) >>> v2=random.random() >>> print(v1>=1) False >>> print(v1==v2) True >>> print(len(random.sample([1,2,3],2)) > 2) False >>> print(random.choice([1,2,3]) >=1) True BD is the answer
upvoted 2 times
...
Noarmy315
2 years, 11 months ago
should be BD print(v1>=1) print(v1==v2) print(len(random.sample([1,2,3],2)) > 2) print(random.choice([1,2,3]) >=1) False True False True
upvoted 1 times
...
wacha1978
3 years, 1 month ago
import random random.seed(1) v1 = random.random() print(v1) random.seed(1) v2 = random.random() print(v2) print(v1==v2) print(len(random.sample([1,2,3],2)) > 2) print(random.choice([1,2,3]) >=1) 0.13436424411240122 0.13436424411240122 True False True
upvoted 1 times
...
vlobachevsky
3 years, 1 month ago
BD is correct
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 ...