Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write Python statements that contains two functions and a main program as follows: A) Write a Python function randomFloats() that gets an integer and a
Write Python statements that contains two functions and a main program as follows: A) Write a Python function randomFloats() that gets an integer and a float number as parameters (lets call them p1 and p2 ), and returns a list of p1 float numbers that are between 0 and p2. The float numbers will be rounded to three decimal digits. Hint: The expression (random.random() * x ) will generate a random number between 0 and x. Hint: Use round() function to perform rounding of numbers. B) Write a Python function list2File() that gets list and a filename as parameters, and writes the elements of the list to the file, each element on a separate line. C) In main program: 1) input an integer number, and a float number, 2) call randomFloats() function to create a list of float numbers, print this list, 3) input a file name, 4) call list2File() function to write the numbers in the list to file. Part 2: Enter size of 1ist: 8 Enter maximum number: 12 [11.348,0.668,5.775,7.457,2.667,5.772,1.974,11.432] Enter filename: 1ab09.txt Numbers are written to file lab09.trt
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