Python Forum

Full Version: Passing parameters with arrays and array definitions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
from array import *

# Must locate and return the smallest value from a list
def find_smallest():
    pass
    

# Must locate and return the largest value from a list
def find_largest():
     pass
    

# Must ask for scores and return them as a list
def get_scores(a):
    for i in range (0,6) :
      input("Please input the scores",a[i])
    return a  

# print title

print("Diving Scores 1b")

scores = array('i', [ 1,2,3,4,5,6,7] )


for j in range (0,6) : 
    print(" The scores are",get_scores(scores[j]))




# Request all 7 scores - call get_scores()

# Request the degree of difficulty - includes decimals (no error checking required)

# calculate and display the final score 
I am not sure how to pass parameters with an array and how to define the input in the function.
if you wish to pass the entire array, just use array name:
and access as shown (i show a different name in the function definition, just to show you can do that, it could be same name or not, your choice)

example:
def show_array(myarray):
    print(myarray)

show_array(scores)