Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have no idea how to code the functions. Please teach me how Codio Project File Edit Find View Tools Education Help Node version Project

I have no idea how to code the functions. Please teach me how

image text in transcribedimage text in transcribed
Codio Project File Edit Find View Tools Education Help Node version Project Index (static) Configure. BFEDELL variable-leng... X 5. 5. Challen... X 1 # Get the filepath from the command line Collapse Data formats import sys P= sys . argv [1] F= sys . argv [2] 6 = sys . argv [3] 5. 5. Challenge: variable length records B= sys . argv [4] 8 # Variable Length Record 10 # 11 # Our Helper functions: Load the pipe-delimited file P . It is organized with 3 fields on each 12 # line: firstname | lastname |birthday. 13 # 14 Search for the firstname F and lastname L , replacing the birthday 15 # with B . Write the file back out in the same pipe-delimited format. 16 Loads the file at filepath 17 # Returns a 2d array with the data Check It! 18 # 19 def load2dArrayFromFile (filepath) : 20 # Your code goes here: 21 X LAST RUN on 10/10/2020, 9:17:54 AM 22 # Program Output 23 # Searches the 2d array 'records' for firstname, lastname. 24 # Returns the index of the record or -1 if no record exists There is an error is your program. 25 # 26 def findIndex (records, firstname, lastname) : 27 # Your code goes here: Sorry: IndentationError: expected an 28 indented block (variable-length. py, line 29 # Sets the birthday of the record at the given index 30 # Returns: nothing 26) 31 def setBirthday (records, index, newBirthday) : 32 # Your code goes here: 33 34 # Convert the 2d array back into a string 35 # Return the text of the 2d array 36 def makeTextFrom2dArray (records) : 37 # Your code goes here: Next 38 39 # 40 41 Our main code body, where we call our functions. 42 # 43 44 46% (28:0) Python Type here to search 09:18 0/10/2020 21 U / IV/LULUC Codio Project Edit Find View Tools Education Help Node version Project Index (static) Configure. BFEDELL variable-leng.. X 5. 5. Challen... X def load2dArrayFromFile (filepath) : 20 # Your code goes here: Collapse Data formats 21 22 # 23 24 # Searches the 2d array 'records' for firstname, lastname. # Returns the index of the record or -1 if no record exists 5. 5. Challenge: variable length records 25 # 26 def findIndex (records, firstname, lastname) : 27 # Your code goes here: Variable Length Record 28 29 # Sets the birthday of the record at the given index Load the pipe-delimited file P . It is organized with 3 fields on each 30 # Returns: nothing line: firstname | lastname | birthday. 31 def setBirthday (records, index, newBirthday) : 32 # Your code goes here: Search for the firstname F and lastname L , replacing the birthday 33 with B . Write the file back out in the same pipe-delimited format. 34 # Convert the 2d array back into a string 35 # Return the text of the 2d array Check It! 36 def makeTextFrom2dArray (records) : 37 # Your code goes here: 38 X LAST RUN on 10/10/2020, 9:17:54 AM 39 40 Program Output 41 Our main code body, where we call our functions. 42 43 # # # # There is an error is your program. # 44 45 # Load our records from the file into a 2d array Sorry: IndentationError: expected an 46 records= load2dArrayFromFile (P) indented block (variable-length. py, line 47 48 # Find out which index, if any, has the name we are hunting 26 ) 49 indexWeAreHunting= findIndex (records, F, L) 50 51 # Set the birthday record to the one we were passed 52 setBirthday (records, indexWeAreHunting, B) 53 54 # Convert the records into a text string 55 output= makeTextFrom2dArray (records) Next 56 57 # Your code goes here 58 # write the text string out to the file 59 found = re. findall(F + ' *' + L + ' *', input_data) 60 input_data = input_data. replace(birthday, B) 46% (28:0) Python Type here to search 09:19 10/10/2020 721

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions