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
A network administrator needs 10 prevent users from accessing the accounting department records. All users are connected to the
mojhsa [17]

Answer:

C

Explanation:

6 0
3 years ago
Read 2 more answers
You want to find the distance between two points.
maks197457 [2]

Answer:

For the first picture, choose the second pair, and for the second one, choose the first pair

Explanation:

5 0
3 years ago
What do you understand by Multiprotocol Label Switching, how it works and is helpful in today's network scenario.
Minchanka [31]

Answer:

Multiprotocol Label Switching (MPLS): It is a routing technique in telecommunications networks that transfers data from 1 node to next node based upon shortest paths instead of long network addresses, hence it avoids rigorous findings in a routing table and speeds the flow of traffic

MPLS provides better performance,scalability,better bandwidth utilization,a better end-user experience and reduced network congestion.Hence it is useful in today's network scenario.

7 0
3 years ago
What section in an ethernet frame will you find a Virtual Local Area Network (VLAN) header?
Vadim26 [7]

Answer:

Preamble

Explanation:

In the computer network , the ether-net is the frame of link layer protocol data. This frame is used ether net with physical layer of transport mechanism. The ether net frame is of different type.

  • The ether-net II
  • The Novel raw IEEE 802.3
  • IEEE 802.2 LLC
  • IEEE 802.2 SNAP

Each of the Ethernet frame started from Ether net header. It contains the source and the destination. The MAC address is called its first two address.

8 0
3 years ago
List and briefly describe the major types of system in organization?​
Anni [7]

The major types of systems in the organization are:

  1. Operational Level system
  2. Management Level system
  3. Strategic Level system  

The classification of information systems based on organization levels is determined by the specialties and interests in some functional areas.

Operational-level systems assist operational managers by tracking the organization's basic operations and transactions, as well as the movement of materials in a factory. The primary function of systems at this level is to respond to routine inquiries and to record the movement of transactions via the organization. In general, information must be easily accessible, up to date, and accurate.

Management-level systems support middle managers' observing, regulating decision-making, and administrative operations. The primary question tackled by such systems is:

  • Are things running smoothly?

Management-level systems usually give regular reports rather than real-time operational data.

Strategic-level systems assist senior management in addressing strategic challenges and long-drawn patterns, both inside the organization and in the external world. Their primary focus is harmonizing external adjustments in the environment with current organizational capacity. 

Therefore, from the above explanation, we can conclude that we've fully understood the types of systems in the organization of information systems.

Learn more about information systems here:

brainly.com/question/13299592?referrer=searchResults

7 0
3 years ago
Read 2 more answers
Other questions:
  • Manuel is working on a project in Visual Studio. He wants to keep this program showing on the entire desktop, but he also needs
    7·1 answer
  • Ok, so this isn't a tech question it's about a game, moomoo.io so don't hate on this if you don't know it, 40 points to whoever
    12·2 answers
  • (50 points) Write a program arrays1.cthat checks if two integer arrays are different by one and only one elementwhen compared el
    5·1 answer
  • Networks that are designed to connect similar computers that share data and software with each other are called:
    10·1 answer
  • What is contrast (in Photography)?
    14·1 answer
  • Fill in the blank with the correct response.
    6·1 answer
  • Please need help.... The system development process is called a cycle. Which of the following may be an ongoing process which su
    6·1 answer
  • Verbs in the active and passive voice
    14·1 answer
  • 2 differences between system and applications software​
    9·2 answers
  • for a given array of integers perform operations on the array return the resulting array after all operations have been applied
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!