Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions

Question

=+5. What are their resources?

Answered: 1 week ago