subject

Variable Length Record

Load the pipe-delimited file P. It is organized with 3 fields on each line: firstname|lastname|birthday.

Search for the firstname F and lastname L, replacing the birthday with B. Write the file back out in the same pipe-delimited format.

Given Code:

# Get the filepath from the command line
import sys
P= sys. argv[1]
F= sys. argv[2]
L= sys. argv[3]
B= sys. argv[4]

#
#
# Our Helper functions:
#
#

#
# Loads the file at filepath
# Returns a 2d array with the data
#
def load2dArrayFromFile(filepath):
# Your code goes here:

#
# Searches the 2d array 'records' for firstname, lastname.
# Returns the index of the record or -1 if no record exists
#
def findIndex(records, firstname, lastname):
# Your code goes here:

# Sets the birthday of the record at the given index
# Returns: nothing
def setBirthday(records, index, newBirthday):
# Your code goes here:

# Convert the 2d array back into a string
# Return the text of the 2d array
def makeTextFrom2dArray(records):
# Your code goes here:

#
#
# Our main code body, where we call our functions.
#
#

# Load our records from the file into a 2d array
records= load2dArrayFromFile(P)

# Find out which index, if any, has the name we are hunting
indexWeAreHunting= findIndex(records, F, L)

# Set the birthday record to the one we were passed
setBirthday(records, indexWeAreHunting, B)

# Convert the records into a text string
output= makeTextFrom2dArray(records)

# Your code goes here
# write the text string out to the file

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
What result from the passage of this amendment
Answers: 1
question
Computers and Technology, 22.06.2019 19:00
How is the number 110 written when expanded out to place values in the base 2 (binary) number system? options: 2 x 4 + 3 x 2 + 4 x 1 1 x 2 + 1 x 2 + 0 x 2 1 x 100 + 1 x 10 + 0 x 1 1 x 4 + 1 x 2 + 0 x 1
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
question
Computers and Technology, 24.06.2019 14:40
Create a function (prob3_6) that will do the following: input a positive scalar integer x. if x is odd, multiply it by 3 and add 1. if the given x is even, divide it by 2. repeat this rule on the new value until you get 1, if ever. your program will output how many operations it had to perform to get to 1 and the largest number along the way. for example, start with the number 3: because 3 is odd, we multiply by 3 and add 1 giving us 10. 10 is even so we divide it by 2, giving us 5. 5 is odd so we multiply by 3 and add one, giving us 16. we divide 16 (even) by two giving 8. we divide 8 (even) by two giving 4. we divide 4 (even) by two giving 2. we divide 2 (even) by 2 to give us 1. once we have one, we stop. this example took seven operations to get to one. the largest number we had along the way was 16. every value of n that anyone has ever checked eventually leads to 1, but it is an open mathematical problem (known as the collatz conjectureopens in new tab) whether every value of n eventually leads to 1. your program should include a while loop and an if-statement.
Answers: 3
You know the right answer?
Variable Length Record

Load the pipe-delimited file P. It is organized with 3 fields on...
Questions
question
Social Studies, 19.08.2020 04:01
question
Mathematics, 19.08.2020 04:01
question
Mathematics, 19.08.2020 04:01
question
Mathematics, 19.08.2020 04:01
question
Mathematics, 19.08.2020 04:01
question
Mathematics, 19.08.2020 04:01
Questions on the website: 13722363