Question: 1.Write a python script that takes an input file and creates a 2 dimensional array Then performs the following FUNCTIONS. ALL HAVE TO BE FUNCTION

1.Write a python script that takes an input file and creates a 2 dimensional array

Then performs the following FUNCTIONS. ALL HAVE TO BE FUNCTION AND INTERACT and work based on an interface.

2.Hailstone Sequence

3.Area of a Circle

4.Print range of each character pair

5.Print range of each numeric pair

6. Eratosthanes Sieve

Here is input file

def SieveOfEratosthenes(n):

# Create a boolean array "prime[0..n]" and initialize
# all entries it as true. A value in prime[i] will
# finally be false if i is Not a prime, else true.
prime = [True for i in range(n + 1)]
p = 2
while (p * p <= n):

# If prime[p] is not changed, then it is a prime
if (prime[p] == True):

# Update all multiples of p
for i in range(p ** 2, n + 1, p):
prime[i] = False
p += 1
prime[0]= False
prime[1]= False
# Print all prime numbers
for p in range(n + 1):
if prime[p]:
print (p) #Use print(p) for python 3

Step by Step Solution

3.29 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 nrows intinputNumber of rows ncolumns intinputNumber of columns Define the matrix matrix printEnte... View full answer

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!