subject
Engineering, 05.05.2020 19:15 jm832098

In this assignment, you are going to write a recursive Python function that is similar to the "reverse" function we have studied in Chapter4 The function is named "consonantReverse". This function will take a string and return a new string (this is because in Python, strings are immutable) that has all consonants in the reverse order of the input string but leaving the vowels in their original place. Here are a few examples: consonantReverse Data') >'taDa' consonantRever 'Algorithms') >'Asmohitrgl' consonantReverse Structures') > 'srtucrutes consonantReverse Datastructures'> saratcrutSuteD' Download the three files "cse220a2Tester. ั€ัƒ", "cse220a2TestData. ั€ัƒ", and "csc220a2.py" from Canvas and save them in the same folder. The first two files are the tester program and the testing data file, respectively. Do not modify these two files. The last file is the file you will work on. Note that you cannot rename this file and you cannot change the name of the function (otherwise the tester will not be able to pick up your implementation). However, you can change the name of the parameter if you like The file "csc220a2.ั€ัƒ" contains a dummy implementation of the function that returns a hard coded incorrect value: def consonantReverse (inputString, start 0, end None): return '' Note that in order to facilitate the recursion, we have added two parameters with default value These two parameters will not be used by the tester, but it is needed by your function to call itself recursively The tester program will use the testing data to test your implementation. It will run a total of 100 test cases. If you have not made any change to the function, it should produce the following output: Passed: [1 - total 0 Failed: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1001 - total 100 0 of 100 test cases passed. Score = 0.00 of 15.00 Notes: You can assume that the input string contains only English letters ('A'-'Z, and any other characters will appear in the input string 1. -2), no 2. Your function should not change the capitalization of characters in the string (see examples above). Your function must be a recursive function 3. 4. Your program will be tested with similar but different data. The testing results will earn you up to 15 points (out of 20 points total) 5. The remaining 5 points will be awarded based on the structure, readability, and documentation of your implementation 6. You implementation should be compatible to Python 3.x. 7. There cannot be any import statement in your program 8. There can be only one single function (the consonantReverse function) in the "csc220a2.ั€ัƒ" file. No other helper method(s) is/are allowed The tester contains a function "runTestCase", this function takes a testcase number and run that single testcase. It will produce a more verbose output to help you debug your program. 9. 10. Your function should have performance linear to the length of the input string This can be a problem since Python strings are immutable. If you return a new string during each recursive step, your function will have O (n2) performance. This is because the returned string during each recursive step will need to be copied, which have an O(n) performance. To solve this problem, we will need to first convert the string into a list of characters, then the reverse operation can be performed on the list, and finally convert the list back into a string. Therefore, you may have to do something similar to the following: def consonantReverse (data, start 0, end - None): if type (data) str: data list (data) consonantReverse (data) return '".join (data)

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:20
Air flows over a heated plate ร t a velocity of 50m/s. the local skin factor coefficient at a point on a plate is 0.004. estimate the local heat transfer coefficient at this point.the following property data for air are given: density = 0.88kg/m3 , viscosity 2.286 x 10 ^-5 kgm/s , k = 0.035w/mk ,cp = 1.001kj/kgk. use colburn reynolds analogy.
Answers: 1
question
Engineering, 04.07.2019 19:20
At steady state, air at 200 kpa, 325 k, and mass flow rate of 0.5 kg/s enters an insulated duct having differing inlet and exit cross-sectional areas. the inlet cross-sectional area is 6 cm2. at the duct exit, the pressure of the air is 100 kpa and the velocity is 250 m/s. neglecting potential energy effects and modeling air as an 1.008 kj/kg k, determine ideal gas with constant cp = (a) the velocity of the air at the inlet, in m/s. (b) the temperature of the air at the exit, in k. (c) the exit cross-sectional area, in cm2
Answers: 2
question
Engineering, 04.07.2019 19:20
Asimple speed reducer is composed of 2 spur gears. the pinion gear has a pitch diameter of 0.75" and 36 teeth while the driven gear has a pitch diameter of 4.0" and 192 teeth. a)-what is the diametral pitch of each gear? b)-if an electric motor rotating ccw at 3000 rpm is coupled to the pinion, what is the rotational speed of the driven gear? c)-if the torque delivered to the pinion is 1 n-m, what is the torque on the driven gear? d)-what is the power transmitted by the gear train?
Answers: 1
question
Engineering, 06.07.2019 03:10
Asolid steel sphere (k=63.9 w m-1 k-1 , ? =7832 kg m-3 , c=0.523 kj kg-1 k-1 ), 100 mm in diameter is initially at a uniform temperature of 500o c and is suddenly quenched in a large oil bath for which t? = 100o c and h = 3200 w m-2 k-1. estimate the time required for the sphere to cool to 200o c and to 110o c
Answers: 1
You know the right answer?
In this assignment, you are going to write a recursive Python function that is similar to the "rever...
Questions
Questions on the website: 13722363