Accept a list of 5 float numbers as an input from the user
Python / Fundamentals of Python
1723
Expected Output:
[78.6, 78.6, 85.3, 1.2, 3.5]
Hints:
- 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 theappend()
function
Program:
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)
Output:
Enter number at location 0 : 12 Enter number at location 1 : 34 Enter number at location 2 : 56 Enter number at location 3 : 78 Enter number at location 4 : 76 User List: [12.0, 34.0, 56.0, 78.0, 76.0]
This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS