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
Instagram
Aleonysh [2.5K]
Uninstall instagram and install it again. log in and go to settings and fix up the notifications maybe that’ll work??

if it doesn’t, go to your apple settings and see if the notifications for instagram are on.

also try shutting your phone off for a few seconds if you do either one.
5 0
3 years ago
Write a void function SelectionSortDescendTrace() that takes an integer array, and sorts the array into descending order. The fu
salantis [7]

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

void SelectionSortDescendTrace(int numbers[], int numElems) {

int maxInd;

for (int i = 0; i < numElems - 1; ++i) {

maxInd = i;

for (int j = i; j < numElems; ++j) {

if (numbers[j] > numbers[maxInd]) {

maxInd = j;

}

}

int temp = numbers[i];

numbers[i] = numbers[maxInd];

numbers[maxInd] = temp;

for (int j = 0; j < numElems; j++) {

cout << numbers[j] << " ";

}

cout << endl;

}

}

int main() {

int numbers[10];

int numElements = 0;

for (int i = 0; i < 10; i++) {

cin >> numbers[i];

if (numbers[i] == -1)

break;

++numElements;

}

SelectionSortDescendTrace(numbers, numElements);

return 0;

}

8 0
3 years ago
Which type of service offers a preconfigured testing environment for application developers to create new software applications
gtnhenbr [62]

The type of service offers a preconfigured testing environment for application developers to create new software applications is Software as a Service (SaaS).

<h3>What is software as a service SaaS?</h3>

Software as a service (SaaS) is known to be a type of service that gives its users the ability to be able to link to and also use cloud-based apps in course of the Internet.

Conclusively, The type of service offers a preconfigured testing environment for application developers to create new software applications is Software as a Service (SaaS) as it gives its best service.

Learn more about application developers  from

brainly.com/question/11352260

#SPJ1

5 0
2 years ago
Off topic lol but does anyone know of a free app that lets you track family and friends like their location? Thx
prohojiy [21]

Answer:Life360 has a free version and a paid

Explanation:Life360 let’s you track family by placing them in “family circles” and then allows you to track their location once they accept the invite to the circle, you May also place specific areas that it will alert them entering and exiting.

4 0
3 years ago
Read 2 more answers
In a Web-based database, middleware is used to transfer information from the organization's internal database back to the Web se
Viefleur [7K]

Answer: True

Explanation:

 Yes, the given statement is true that the web based database used the various types of database applications for transferring the information or data.

  • The web database applications are basically designed so that the users managed and easily access the information by using the internet.
  • It is works as the middleware form for transferring the data from the internal database of an organization to the web server and it is known as web page for the user interface.
  • We can store various types of business and also personal related data by using the web database.

4 0
3 years ago
Other questions:
  • When you declare an array, _____________________ You always reserve memory for it in the same statement You might reserve memory
    9·1 answer
  • an object or device outside the computer, that one would plug into a port to control the functions of a computer are?
    9·2 answers
  • When you compose a message, you want your audience to find the information it needs quickly and to understand what it finds. You
    11·1 answer
  • All but one of the following statements about stored procedures is true. Which one is false? a. They consist of one or more SQL
    10·1 answer
  • Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicatin
    10·1 answer
  • (1 consider the following function definition: int func(int x, double y, char u, string name { //function body } which of the fo
    7·1 answer
  • A wide variety of apps are available to customize devices, which category of app does word processing software falls into?
    10·1 answer
  • What do you think about the future of computers?​
    14·1 answer
  • Please help with the question no. 5 and 7 please help ​
    6·1 answer
  • Disadvantages of computer. ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!