Question: Python Create a list x containing the prime numbers in ascending order from 1 to 100 using a for-loop. To check your answer, the output

Python

  • Create a list x containing the prime numbers in ascending order from 1 to 100 using a for-loop.
    • To check your answer, the output of print(x[:3]) should be [2, 3, 5] and print(x[-3:]) should be [83, 89, 97].
    • Hint: % will get the remainder from integer division, e.g. 10 % 3 will yield 1
  • Please create a variable, a, that stores the number of prime numbers greater than 30 and less than 80.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!