Python Forum
Passing parameters with arrays and array definitions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing parameters with arrays and array definitions
#1
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.
Larz60+ write Jul-07-2022, 09:42 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Reply
#2
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 447 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  Definitions in User-Created Functions and For Loops new_coder_231013 6 2,106 Dec-29-2021, 05:51 AM
Last Post: ndc85430
  Element misalignment passing numpy array with distutils OTAGOHARBOUR 1 2,063 Dec-06-2019, 01:47 AM
Last Post: OTAGOHARBOUR
  'Get closest value array in array of arrays.' follow up help. DreamingInsanity 10 7,306 Dec-05-2019, 06:30 PM
Last Post: DreamingInsanity
  Get closest value array for array of arrays. DreamingInsanity 2 2,351 Nov-18-2019, 03:55 PM
Last Post: DreamingInsanity
  Passing parameters to SQL Server using pandas Ilangos 8 16,499 Jun-03-2019, 11:25 AM
Last Post: Ilangos
  How do I split a large array into smaller sub-arrays? codebeacon 3 4,143 Apr-08-2019, 03:45 AM
Last Post: codebeacon
  how to work with variables changed in definitions Prof_Jar_Jar 2 2,623 Dec-16-2018, 12:04 AM
Last Post: Prof_Jar_Jar
  Passing parameters from C# to Python[for using in gensim] in Visual Studio 2017 ZoghbyAya 0 3,873 May-21-2018, 08:49 PM
Last Post: ZoghbyAya

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020