A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Accept a list of 5 float numbers as an input from the user using python programming
Q:

Accept a list of 5 float numbers as an input from the user using python programming

0

Accept a list of 5 float numbers as an input from the user

Expected Output:

[78.6, 78.6, 85.3, 1.2, 3.5]

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Hint:

  • Create a list variable named numbers
  • Run loop five times
  • In each iteration of the loop, use the input() function to take input from a user
  • Convert user input to float number using the float() constructor
  • Add float number to the numbers list using the append() function

Solution:

numbers = []

# 5 is the list size
# run loop 5 times
for i in range(0, 5):
    print("Enter number at location", i, ":")
    # accept float number from user
    item = float(input())
    # add it to the list
    numbers.append(item)

print("User List:", numbers)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now