1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andreas93 [3]
3 years ago
9

def getCharacterForward(char, key): """ Given a character char, and an integer key, the function shifts char forward `key` steps

. Return the new character. If `char` is not a single character, return `None`. If `key` is not an integer, return -1. """ return "stub"
Computers and Technology
1 answer:
zhenek [66]3 years ago
8 0

Answer:

  1. def getCharacterForward(char, key):  
  2.    charList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  3.    if(len(char) > 1):
  4.        return None  
  5.    elif(not isinstance(key, int)):
  6.        return -1
  7.    else:
  8.        index = charList.find(char)
  9.        if(index + key <= 25):
  10.            return charList[index + key]
  11.        else:
  12.            return charList[(index + key)% 26]
  13. print(getCharacterForward("C", 4))
  14. 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

You might be interested in
If several programs or apps are running simultaneously, your computer or device might use up its
kirill [66]

Answer: I am pretty sure it's RAM

Explanation:

I'm not 100% positive bc I haven't gotten my scores back yet but I think that's it.

7 0
3 years ago
What would happen if you clicked on the Show Desktop icon on your computer screen? The system tray would appear. All open window
Sholpan [36]
<span> All open windows would be minimized</span>
7 0
3 years ago
Read 2 more answers
What different factors would you consider when deciding whether to implement a catch-up mechanic in a single-player game vs. a m
LuckyWell [14K]

Answer:

2.As the name defines that over-the-shoulder perspective, this is the camera position where the viewer can see the front view of the game, like this position is from the back or from the shoulder’s so the player can easily judge the game and play the game easily. So this position is very popular in the games. Furthermore, if we talk about this position according to the first person, this is the same like you are watching from the player’s eye and this makes the game more attention seeker for the player and also those who are watching the game. Likewise, the second person is not much important in the game because this is not controlled by the player but the second person is focused on the player’s action, so the camera position is much less important for the second person. Similarly, the third person is more important than the second person. The third person usually practical consideration like this makes the situation clearer and easier for the player and draws a very clear picture to everyone.

3.When you are talking about the games and building a very interactive game, then this is very important that the game should have some logic and goals. Without a goal and illogic games not lasts a good thought. Catch up mechanics specifically use to define some kind of rewards and goals in the game that will be helpful for the player. Similarly, the single-player games are more interactive as compared to the multi-player because multi-player involve many other people who will be not accepted easily. I catch up mechanics involved in the single-player then this does not mean that you are giving a chance again to win instead to end the game quickly. While using the AI in games for both types, this will give a much higher interactive level and entertaining level. Not every player can take the difficulty level that can be offered after the AI, but after combining the AI with the catch-up mechanics, the game level becomes higher with every perspective.

:)

4 0
3 years ago
Which agency was the BBG a part of until September 1999?
valentinak56 [21]

Answer:

O A. United States Information Agency

Explanation:

The BBG was the part of the United States Information Agency till 1999. This is the affiliate relations and media training office. And it was headquartered in Washington DC.  Hence, the most appropriate answer out here, and in fact the correct option for this question is A., and which is United States Information Agency.

4 0
3 years ago
A hierarchical topology is also called a _____ topology.
Vedmedyk [2.9K]
It is also called a tree topology.it combines computers with different strengths in different organizational levels.<span />
5 0
4 years ago
Other questions:
  • What important Apple computer (with a GUI OS) was introduced in 1984? Apple I?
    13·1 answer
  • Cover page styles in the cover page gallery match the preformatted styles in word, making it easier to create a coherent style b
    5·1 answer
  • What is the best use of a line chart?
    7·1 answer
  • How do i end my current plan that i never signed up for, the basic one it charged me $24
    11·2 answers
  • Why is updating your anti-virus a good thing?
    13·1 answer
  • Assume that we have an application with a total of 500,000 instructions where 20% of them are the load/store instructions with a
    14·1 answer
  • 9.1.3: Printing vector elements with a for loop. Write a for loop to print all NUM_VALS elements of vector courseGrades, followi
    5·1 answer
  • Why did my typing suddenly become delayed, but then went back to normal a few minutes later. Is this spyware or smth?
    6·1 answer
  • What is the difference between business strategies and business models?
    9·1 answer
  • The analysis of attempting to solve a problem with information systems is called ________.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!