Home / Expert Answers / Computer Science / please-write-this-code-in-python-irite-a-program-that-asks-the-user-to-enter-the-amount-of-numb-pa163

(Solved): Please write this code in python Irite a program that - asks the user to enter the amount of numb ...



Irite a program that
- asks the user to enter the amount of numbers to be written to a file - creates a new file test.txt andExample for testing [ I used random.seed(1) for those numbers]:
How many numbers are needed to write to the file: 15
\[
18739

Please write this code in python

Irite a program that - asks the user to enter the amount of numbers to be written to a file - creates a new file test.txt and writes to it a predetermined amount of random numbers (use the constant sequence created by using the random.seed() function) - determines how many of the entered numbers are primes - writes primes number in the file prime.txt - displays (in the shell window) - all numbers in the file - the list of prime numbers - the total quantity of prime numbers 1. The program should work with a text file of any length if it contains one number per line. The file should have no empty (blank) lines, including at the very end of the file. 2. The program should include error handling for entering numbers and working with files. Example for testing [ I used random.seed(1) for those numbers]: How many numbers are needed to write to the file: 15 \[ 18739893316649858618449271363 \] 736113 3 prime numbers found in this file \( ========== \) Extra Assignment 1 ( 10 more points) 1. Create a new function which calculates the sum of digits of any integer number and write this function to a separate module. 2. Call this function and determine which number in the file test.txt has a biggest sum of digits.


We have an Answer from Expert

View Expert Answer

Expert Answer


Program: import random as r def prime(data): res=[] for i in data: k=0 for j in range(2,i//2+1): if i%j==0: k=1 break if k==0: res.append(i) return re
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe