Skip to content

Instantly share code, notes, and snippets.

@jetnew
Created April 19, 2018 10:33
Show Gist options
  • Save jetnew/2293846223168aea15034b316ac19d30 to your computer and use it in GitHub Desktop.
Save jetnew/2293846223168aea15034b316ac19d30 to your computer and use it in GitHub Desktop.
Jet_New_Python_Project_1 created by GitHJet - https://repl.it/@GitHJet/JetNewPythonProject1
# Import library to use the function 'random.randint()'.
import random
# User-defined function to print list details.
def list_details(l_length, l_bound, u_bound):
# Create an empty list to load values in.
v_list = []
# Use a for-loop to append random integers into the list.
for i in range(l_length):
v_list.append(random.randint(l_bound, u_bound))
# Print details of the list.
print("Sequence:", v_list)
print("List length:", l_length)
print("Largest integer:", max(v_list))
print("Smallest integer:", min(v_list))
print("Total sum of the integers in the list:", sum(v_list))
print("Average of the integers in the list", sum(v_list) / l_length)
# End the user-defined function with 'return'.
return
# Request the user for inputs required and assign them to a variable.
list_length = int(input("Please enter the length for the list:"))
lower_bound = int(input("Please enter the lower bound for the range of integer values:"))
upper_bound = int(input("Please enter the upper bound for the range of integer values:"))
# Run the user-defined function.
list_details(list_length, lower_bound, upper_bound)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment