7 Sequences: Strings, Files Inputs and drifters 1. Write a function that accepts a date as a string of the form YYYY-MM-DD and returns the day number since the beginning of the year and the date in...

What is the code for part 3 and 4 of the assignment? I have no idea what it wants, should look like, or the results.


7 Sequences: Strings, Files Inputs and drifters 1. Write a function that accepts a date as a string of the form YYYY-MM-DD and returns the day number since the beginning of the year and the date in years. The date in years is defined as the year plus dayNumber/365 or dayNumber/366 depending whether the year is leap or not. Try your code on the following dates: 2019-03-01, 2020-03-01, 2020-12-31. Feel free to reuse any previous code you have developed. The function should have the following interface: def dayOfYear(datestring) return dayNumber, yearunits 2. Write a function that accepts time as a string of the form hh:mm:ss and returns it as the number of seconds The function should have the following interface: def timestring2seconds(timestring) return timeinseconds Try your code on the time 04:30:30, 18:24:00 and 23:59:59. 3. A list of files have the form CARTHE_zzz.dat where zzz is a 3-digit number corre- sponding to the tag ID of a drifter . Write a for loop that generates the file names sequentially for 1<=><= 20="" ,="" and=""><= tag=""><= 105. the function interface should be of the form: def generatefilename(prefix,tag,suffix): return filename note: the string method format will help translate ’{:03}’.format(tag) will trans- form the number tag to a 3-digit string zzz. 4. use the results of exercise 3 to read the data files of carthe drifters 4–8. plot each trajectory with a di↵erent color marking the beginning and end of the trajectories with a circle, ’o’, and asterisk, ’*’, respectively. please start from the plotting functions shown in class and modify them to fit your tasks (don’t rewrite a new function for every color). the data is located in box in folder datacollections/carthedrifters. feel free to copy the files to your local folder to run the experiments, alternatively you can use a relative path name to refer to the files. 14 variables and expressions in simple programs numerical programming and functions program flow: branching structures looping structures functions-revisited sequences and graphics graphics sequences: strings, files inputs land drifters sequences: lists sequences types and their uses file i/o graphics linear regression computing a trajectory computing trajectories 105.="" the="" function="" interface="" should="" be="" of="" the="" form:="" def="" generatefilename(prefix,tag,suffix):="" return="" filename="" note:="" the="" string="" method="" format="" will="" help="" translate="" ’{:03}’.format(tag)="" will="" trans-="" form="" the="" number="" tag="" to="" a="" 3-digit="" string="" zzz.="" 4.="" use="" the="" results="" of="" exercise="" 3="" to="" read="" the="" data="" files="" of="" carthe="" drifters="" 4–8.="" plot="" each="" trajectory="" with="" a="" di↵erent="" color="" marking="" the="" beginning="" and="" end="" of="" the="" trajectories="" with="" a="" circle,="" ’o’,="" and="" asterisk,="" ’*’,="" respectively.="" please="" start="" from="" the="" plotting="" functions="" shown="" in="" class="" and="" modify="" them="" to="" fit="" your="" tasks="" (don’t="" rewrite="" a="" new="" function="" for="" every="" color).="" the="" data="" is="" located="" in="" box="" in="" folder="" datacollections/carthedrifters.="" feel="" free="" to="" copy="" the="" files="" to="" your="" local="" folder="" to="" run="" the="" experiments,="" alternatively="" you="" can="" use="" a="" relative="" path="" name="" to="" refer="" to="" the="" files.="" 14="" variables="" and="" expressions="" in="" simple="" programs="" numerical="" programming="" and="" functions="" program="" flow:="" branching="" structures="" looping="" structures="" functions-revisited="" sequences="" and="" graphics="" graphics="" sequences:="" strings,="" files="" inputs="" land="" drifters="" sequences:="" lists="" sequences="" types="" and="" their="" uses="" file="" i/o="" graphics="" linear="" regression="" computing="" a="" trajectory="" computing="">
Mar 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here