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
Step: 1
1 nrows intinputNumber of rows ncolumns intinputNumber of columns Define the matrix matrix printEnte...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started