Answer:
- def getCharacterForward(char, key):
- charList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-
- if(len(char) > 1):
- return None
- elif(not isinstance(key, int)):
- return -1
- else:
- index = charList.find(char)
- if(index + key <= 25):
- return charList[index + key]
- else:
- return charList[(index + key)% 26]
-
- print(getCharacterForward("C", 4))
- print(getCharacterForward("X", 4))
Explanation:
Firstly, define a charList that includes all uppercase alphabets (Line 2). We presume this program will only handle uppercase characters.
Follow the question requirement and define necessary input validation such as checking if the char is a single character (Line 4). We can do the validation by checking if the length of the char is more than 1, if so, this is not a single character and should return None (Line 5). Next, validate the key by using isinstance function to see if this is an integer. If this is not an integer return -1 (Line 6 - 7).
Otherwise, the program will proceed to find the index of char in the charList using find method (Line 9). Next, we can add the key to index and use the result value to get forwarded character from the charList and return it as output (Line 11).
However, we need to deal a situation that the char is found at close end of the charList and the forward key steps will be out of range of alphabet list. For example the char is X and the key is 4, the four steps forward will result in out of range error. To handle this situation, we can move the last two forward steps from the starting point of the charList. So X move forward 4 will become B. We can implement this logic by having index + key modulus by 26 (Line 13).
We can test the function will passing two sample set of arguments (Line 15 - 16) and we shall get the output as follows:
G
B
When a computer restarts without a hardware power-down-power-up cycle, it is doing an update.
Answer:
Optical Character Recognition
Explanation:
Optical Character Recognition is a method that is used to read character and bar codes. They convert scanned image into digital format. In other words ASCII text can be formed when a digitized document is converted.OCR is a method that convert document into word.
Here are some OCR tools which convert digitized format into machine readable text.
- Microsoft Document
- Microsoft One Note
It is called a Cooperative program
A Cooperative program refers to a combination of both academic study and vocational activities in one curriculum of education. The purpose of this program is to provide the students with both knowledge in theory and practical skills that make them more prepared in the real world.
Answer:
Chech the explanation
Explanation:
<em>In [16]:</em>
<em />
# Your answer to this question might be written on more than a line.
datascience_trials = make_array()
for i in np.arange(1000):
datascience_trials = np.append(datascience_trials, simulate_several_key_strikes(1))
datascience_proportion = np.count_nonzero(datascience_trials == 'datascience')/1000
datascience_proportion
<em>Out [16]:</em>
0.0
<em>In [17]:</em>
_ = ok.grade('q2_4')
````````````````````````````````````````````````````````````````````````````````````````````````````````
#Running tests