subject

#Write a function called "num_changer" that accepts a string #of digits (0-9). You should make an integer from the digits #of the even indices and another number from the digits in #the odd indices. Return the sum of these two numbers. You #can assume the given string will have a length of at least #2 digits. # #For example, if the string was "123456", you would split #this into two integers, 135 and 246. Adding them would give #381. Or if the string was "13579", you would split this into #159 and 37, then add them to get 196. # #Hint: You can do this with loops, but it's easier to do #this with string slicing. Remember how we could pass a third #argument to range() that would tell range how many numbers #to skip? You can do something similar with string slices: if #you include second colon in a string slice, the number #that follows it lets you skip characters in the string. For #example: # # "Hello, world!"[1:9] -> This gives "ello, wo". # "Hello, world!"[1:9:2] -> This gives "el, w". Including :2 # in the string slice skips every other letter. # "Hello, world!" [::3] -> This gives "Hl r!". Leaving the # first two spots blank tells it to look at the entire # string, but putting :3 at the end says to only take # every third character (H, l, space, r, and !). # #Hint 2: Remember, Python is zero-indexed. That means the #first number in the string is at position 0, and so it goes #in the even list.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:00
Which best compares appointments and events in outlook 2010appointments have a subject man, and events do notappointments have a specific date or range of dates, and events do notappointments have a start and end time of day, and events do notappointments have a location option, and events do not
Answers: 2
question
Computers and Technology, 24.06.2019 16:00
Your is an example of personal information that you should keep private.
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
To fill (copy) a cell across or down, point to the of the cell and drag. top left corner top right corner bottom left corner bottom right corner
Answers: 3
question
Computers and Technology, 24.06.2019 21:30
Computer security/cybersecurity1) each of the following code fragments contains a number of security vulnerabilities. for each fragment, identify these security vulnerabilities and, for each vulnerability, discuss at least one way that it could be improved. note that in your discussion of how each vulnerability could be improved, you do not need to re-write a new version of the program in c; simply discuss your solution, either in pseudocode or in 1-2 sentences.a) /* file descriptor leak */#include #include int main(int argc, char *argv[]){ char *filepath = argv[0]; char *shellpath = argv[1]; file *passwords; passwords = fopen(filepath, "r"); /* read the password and do something with it */ /* . . */ /* fork and execute alternative shell */ execl(shellpath, "shell", null); }b)#include /* assume the following function is written for an electronic storefront. the user will enter the id of the item to be ordered, as well as the quantity of units that they would like to purchase. the program will then lookup the price for the price for the item using a predefined function, and return the total cost of the order.*/int gettotalcost(){ char itemid[9]; int price, unitsordered, cost; printf(" enter the 9-digit id of the item to be ordered: "); scanf("%s", & itemid); /* lookup the price according to the itemid */ price = getpricebyid(itemid); printf(" enter the quantity of units to be ordered: "); scanf("%d", & unitsordered); cost = price * unitsordered; return cost; }c)#include /* the following function is intended to return a user's full name by concatenating the user's first and last name into a single string and then returning that string. */char *getfullname(char *firstname, char *lastname, int max_len){ char fullname[max_len]; strcpy(fullname, firstname); strcat(fullname, " "); strcat(fullname, lastname); return fullname; }d)#include /* the following code snippet runs through the list of cli arguments entered and displays them to the console. */int main(int argc, char *argv[]){ int i; printf("you've entered the following arguments: "); for(i = 0; i < argc; i++){ print(argv[i]); printf("\n"); } /* */}
Answers: 2
You know the right answer?
#Write a function called "num_changer" that accepts a string #of digits (0-9). You should make an in...
Questions
question
Computers and Technology, 14.04.2021 02:40
question
Biology, 14.04.2021 02:40
question
Mathematics, 14.04.2021 02:40
Questions on the website: 13722360