String operations

Ace your homework & exams now with Quizwiz!

Neriah is writing code for a website that publishes attention-grabbing news articles. The code relies on multiple string operations: Pseudocode Description CONCATENATE(string1, string2) Concatenates (joins) two strings to each other, returning the combined string. UPPER(string) Returns the string in uppercase. Her code uses these variables: title1 ← "Cat rips Xmas tree to shreds" title2 ← "Cat stuck in tree for weeks" title3 ← "New world record: fluffiest cat ever" Which of the following expressions results in the string "CAT STUCK IN TREE FOR WEEKS!!!"? 👁️Note that there are 2 answers to this question.

CONCATENATE( UPPER(title2), "!!!") UPPER( CONCATENATE(title2, "!!!") )

Barry is making a program to process user birthdays. The program uses the following procedure for string slicing: Name Description SUBSTRING (string, startPos, numChars) Returns a substring of string starting at startPos of length numChars. The first character in the string is at position 1. His program starts with this line of code: userBday ← "03/31/1984" Which of these lines of code displays the month ("03")?

DISPLAY (SUBSTRING (userBday, 1, 2))

Barry is making a program to process user birthdays. The program uses the following procedure for string slicing: Name Description SUBSTRING (string, startPos, numChars) Returns a substring of string starting at startPos of length numChars. The first character in the string is at position 1. His program starts with this line of code: userBday ← "03/31/84" Which of these lines of code displays the day of the month ("31")? Choose 1 answer:

DISPLAY (SUBSTRING (userBday, 4, 2))

Kunto is working on a program for generating baby name ideas. Her program uses the following procedure for string concatenation: Pseudocode Description concatenate(string1, string2) Concatenates (joins) two strings to each other, returning the combined string. These variables are at the start of her program: first1 ← "Ella" first2 ← "Kai" mid1 ← "Mae" mid2 ← "Lynn" Which line of code would store the string "Kai Lynn"?

name ← concatenate(concatenate(first2, " "), mid2)

Aden is working on a program that can generate domain names. His program uses the following procedure for string concatenation: Pseudocode Description concatenate(string1, string2) Concatenates (joins) two strings to each other, returning the combined string. These variables are at the start of his program: company ← "cactus" tld1 ← "com" tld2 ← "io" Which line of code would store the string "cactus.io"? Choose 1 answer:

name2 ← concatenate(company, concatenate(".", tld2))

Regina is writing a program to process user-inputted phone numbers. The program relies on multiple string operations: Pseudocode Description CONCAT(string1, string2) Concatenates (joins) two strings to each other, returning the combined string. TRIM(string) Removes any whitespace at the beginning or end of string. Here's a snippet of her code: userPhone ← " 202-555-0183 " usCode ← "+1" usPhone ← CONCAT(usCode, TRIM(userPhone)) What value does the usPhone variable store?

"+1202-555-0183"

Ling is writing code for a browser extension that transforms online comments to sound less emotional. The code relies on multiple string operations: Pseudocode Description LOWER(string) Returns the string in lowercase. REMOVE(string, target) Removes all occurrences of target from string and returns the new string. Their code includes these variables: commentA ← "ISN'T IT OBVIOUS?!!!" commentB ← "YOU'RE SO SILLY!!!!" commentC ← "I DON'T BELIEVE YOU!!!" Which of the following expressions results in the string "you're so silly"? 👁️Note that there are 2 answers to this question.

REMOVE( LOWER(commentB), "!") LOWER( REMOVE(commentB, "!"))

Ayaan is writing a program that generates wizard spells. The program relies on multiple string operations: Pseudocode Description CONCAT(string1, string2) Concatenates (joins) two strings to each other, returning the combined string. UPPER(string) Returns the string in uppercase. Here's a snippet of his code: start ← "Bibbidi Bobbidi" end ← "Boo" spell ← CONCAT(start, UPPER(end)) What value does the spell variable store?

bibbidibobbidiBOO


Related study sets

Handbook for Real Estate Examinations and Practice - Chapter 9 - Appraisal of Real Estate - MA Real Estate

View Set

MKTG 3711 Final exam Study Guide

View Set

Exploring Culture-Unit Test Study

View Set

nur 2990 - prepu - oncologic disorders

View Set

Unit 4 The Bohr Model Revisited OW

View Set