Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Essentially in python this my code and I want this output if a range is selected 5:7!11&13:17!19&23 or just 1 number it is only one
Essentially in python this my code and I want this output if a range is selected 5:7!11&13:17!19&23 or just 1 number it is only one and finally no primes if there is no prime numbers. however I am not able to achieve it. def primenumbers(num1,num2): results = [] for num in range(num1, num2 + 1): # all prime numbers are greater than 1 if num > 1: for i in range(2, num): if (num % i) == 0: break results.append('No Primes') else: results.append(str(num)) #print(results) #results = list(map(int, results)) return results #Function to print the desired output def printOutput(result): list2 = [':', '!', '&'] output = '' for i in range(1,len(result)): output =print(str(result[i%len(result)])+list2[i%len(list2)],end = '') return output def main(): num1 = 5 num2 = 25 primenumbers(num1, num2) results = primenumbers(num1, num2) printOutput(results) if __name__ == '__main__': main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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