A digital artist is creating an animation with code. Their code needs to convert polar coordinates to cartesian coordinates, using these formulas:
x = r × cos( θ )y = r × sin( θ )x=r×cos(θ)y=r×sin(θ)
The environment provides these built-in procedures:
NameDescriptionsin(angle)Returns the...
The following code snippet processes a list of strings with a loop and conditionals:
words ← ["belly", "rub", "kitty", "pet", "cat", "water"] counter ← 0 FOR EACH word IN words { IF
(FIND(word, "e") = -1 AND FIND(word, "a") = -1) { counter ← counter + 1 } } DISPLAY(counter)
,The code relies on one string procedure, FIND(source, target), which returns the first index of the string
target inside of the string source, and returns -1 if target is not found.
What value will this program display? correct answer2
Lucie is developing a program to assign pass/fail grades to students in her class, based on their
percentage grades.
Their college follows this grading system:
PercentageGrade70% and abovePASSLower than 70%FAIL
The variable percentGrade represents a student's percentage grade, and her program needs to set grade
to the appropriate value.
Which of these code segments correctly sets the value of grade?
👁️Note that there are 2 answers to this question. correct answerIF (percentGrade ≥ 70) { grade ←
"PASS" } ELSE { grade ← "FAIL" }
The program code is shown below, but it is missing three values: <COUNTER>, <AMOUNT>, and <STEP>.
i ← <COUNTER> REPEAT <AMOUNT> TIMES { DISPLAY(i) DISPLAY(i + 1) i ← i + <STEP> }
Given the displayed output, what must the missing values be? correct answer<COUNTER> = 4,
<AMOUNT> = 2, <STEP> = 1
This program uses a conditional to predict the hair type of a baby.
IF (fatherAllele = "C" AND motherAllele = "C") { hairType ← "curly" } ELSE { IF (fatherAllele = "s" AND
motherAllele = "s") { hairType ← "straight" } ELSE { hairType ← "wavy" } }
In which situations will hairType be "wavy"?
👁️Note that there may be multiple answers to this question. correct answerWhen fatherAllele is "s" and
motherAllele is "C"
When fatherAllele is "C" and motherAllele is "s"
,Darrell is making a program to track his grades. He made the mistake of using the same variable name to
track 3 different test grades, though. Here's a snippet of his code:
a ← 89 a ← 97 a ← 93
What will be the value of a after this code runs? correct answer93
The following procedure calculates the slope of a line and takes 4 numeric parameters: the x coordinate
of the first point, the y coordinate of the first point, the x coordinate of the second point, and the y
coordinate of the second point.
This graph contains a line with unknown slope, going through the points [1, 1][1,1]open bracket, 1,
comma, 1, close bracket and [3, 4][3,4]open bracket, 3, comma, 4, close bracket:
What does the localFavs variable store after that code runs? correct answer"Udupi", "The Flying Falafel",
"Gaumenkitzel", "Rojbas Grill", "Platano", "Cafe Nostos"
Aden is working on a program that can generate domain names.
His program uses the following procedure for string concatenation:
PseudocodeDescriptionconcatenate(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"? correct answername2 ← concatenate(company,
concatenate(".", tld2))
This program simulates a game where two players try to make basketball shots . Once either player
misses 5 shots, the game is over.
Part 1: How many statements are in the above program?
Part 2: What does the program output? correct answer3
Mister Splashy Pants
Nanami is researching how much software engineers make. She's writing a program to convert yearly
salaries into hourly rates, based on 52 weeks in a year and 40 hours in a week.
The program starts with this code:
salary ← 105000 wksInYear ← 52 hrsInWeek ← 40
Which lines of code successfully calculate and store the hourly rate?
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller EAGLE5. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $11.99. You're not tied to anything after your purchase.