Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Define two functions in an IDLE Editor window: get floats(): This function will take a single integer argument which is the number of floats

Python

Define two functions in an IDLE Editor window:

get floats(): This function will take a single integer argument which is the number of floats to be obtained from the user. It will create an empty list, use a for-loop to prompt and obtain floats from the user, append each float to the list it created, and return the list.

main(): This function will take no arguments. It will prompt the user for the number of floats s/he wants to enter, and it will call get floats() with the integer value entered by the user. A list will be returned to main() which will then print the results. The output for both functions is shown below.

Enter the number of list elements: 3

Enter float 1: 25.1

Enter float 2: 19.3

Enter float 3: 47.8

[25.1, 19.3, 47.8]

Enter the number of elements: 4

Enter float 1: 2

Enter float 2: 4

Enter float 3: 8

Enter float 4: 10

[2.0, 4.0, 8.0, 10.0]

Dont forget to include a call to main(). Hints: Dont forget to convert your input as appropriate. A simple one-argument range() function can be used as the iterable in the for-loop header.

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

Students also viewed these Databases questions