20. Consider an algorithm intending to store all prime numbers between 2 and 20 (inclusive) in a list prime_list. There exists a helper function called is_prime(n) which returns True if n is prime and...


20. Consider an algorithm intending to store all prime numbers between 2 and 20 (inclusive) in a list prime_list. There<br>exists a helper function called is_prime(n) which returns True if n is prime and False if n is not prime.<br>i = 1<br>prime_list = [0|<br>while i <= 10:<br>#missing code<br>Which of the following can be used replace the missing code?<br>(a) if is_prime(2*i):<br>prime_list.append(2*i)<br>i = i+ 1<br>(b) if is_prime(2*i):<br>prime_list.append(2*i)<br>i = i+ 1<br>(c) if is_prime(i):<br>prime_list.append(2*i)<br>i = i+ 1<br>(d) prime_list.append(is_prime(2*i))<br>i = i+ 1<br>

Extracted text: 20. Consider an algorithm intending to store all prime numbers between 2 and 20 (inclusive) in a list prime_list. There exists a helper function called is_prime(n) which returns True if n is prime and False if n is not prime. i = 1 prime_list = [0| while i <= 10:="" #missing="" code="" which="" of="" the="" following="" can="" be="" used="" replace="" the="" missing="" code?="" (a)="" if="" is_prime(2*i):="" prime_list.append(2*i)="" i="i+" 1="" (b)="" if="" is_prime(2*i):="" prime_list.append(2*i)="" i="i+" 1="" (c)="" if="" is_prime(i):="" prime_list.append(2*i)="" i="i+" 1="" (d)="" prime_list.append(is_prime(2*i))="" i="i+">

Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here