Test answers cs

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

r <- 1 s <- 2 t <- 3 r <- s s <- t DISPLAY(r) DISPLAY(s) a: 1 2 b: 2 3 c: 1 1 d: 3 2

2 3

start <- 1 end <- 20 current <- 3 start <- current current <- current + 1 DISPLAY(start) DISPLAY(current) What is displayed as a result of executing this program? a: 1 3 b: 3 3 c: 3 4 d: 4 4

3 4

result <- 4+ -2 * 3 DISPLAY(result) what is displayed from the above code a: -2 b: 6 c: 18 d: 10

a: -2

The following algorithm is intended to take a positive integer as input and display its individual digits in order from right to left. For example, if the input is 512, the algorithm should produce the output 2 1 5. Step 3 of the algorithm is missing. Step 1: Input a positive integer from the user and store it in the variable number Ste 2: Divide number by 10 and record the integer quotient and the remainder. The integer quotient is the quotient with any part after the decimal point dropped. For example, when 127 is divided by 10, the quotient is 12.7, the integer quotient is 12 and the remainder is 7 Step 3: (missing step) Step 4: Repeat steps 2 and 3 until number is 0 Which of the following can be used as step 3 so that the algorithm works as intended? a: Step 3: Display the remainder of number divided by 10 and store the integer quotient in number b: Step 3: Display the remainder of number divided by 10 and store the remainder in number c: Step 3: display the integer quotient of number divided by 10 and store the integer quotient in number d: Step 3: Display the integer quotient of number divided by 10 and store the remainder in number

a: Step 3: Display the remainder of number divided by 10 and store the integer quotient in number

Directions: two correct answers below Which of the following are benefits of using well-named variables in a computer program? a: the program will be easier to modify in the future b: the program will be easier to read c: the program will have a greater data storage capacity d: the program will run faster

a: the program will be easier to modify in the future b: the program will be easier to read

Directions: Two answers below are correct A school library allows students to borrow laptops. A computer program is used to count the number of times a particular laptop has been borrowed (borrows) from the library and the number of times the same laptop has been returned (returns) to the library. Which of the following indicate that a particular laptop is not currently borrowed? a: the sum of borrows and returns is a positive even number b: the quotient when borrows is divided by returns is greater than 1 c: the product of borrows and returns is a positive even integer d: the difference between borrows and returns is zero

a: the sum of borrows and returns is a positive even number d: the difference between borrows and returns is zero

a <- expression Evaluates expression and then assigns a copy of the result to the variable a p <- 10 q <- 20 r <- 30 s <- 40 p <- q q <- r s <- q r <- p What is the value of r as a result of executing the code segment? a: 10 b: 20 c: 30 d: 40

b: 20

x <- 23 z <- x MOD y Which of the following initial values of the variable y would result in the variable z being set to 2 after the code segment is executed? a: 1 b: 2 c: 3 d: 4

c: 3

2.5*2+8/5+10//3 a: 9.9999999 b: 9.0 c: 9.6 d: 8.0

c: 9.6

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer's goal of changing all occurrences of "goats" to "sheep" and all occurrences of "sheep" to "goats". The programmer will use the fact that the word "foxes" does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish the programmer's goal? a: First, change all occurrences of "goats" to "sheep" Then, change all occurrences of "sheep" to "goats" b: First, change all occurrences of "goats" to "sheep". Then, change all occurrences of "sheep" to "goats". Last, change all occurrences of "foxes" to "sheep" c: First, change all occurrences of "goats" to "foxes". Then, change all occurrences of "sheep" to "goats". Last, change all occurrences of "foxes" to "sheep" d: First, change all occurrences of "goats" to "foxes". Then, change all occurrences of "foxes" to "sheep". Last, change all occurrences of "sheep" to "goats"

c: First, change all occurrences of "goats" to "foxes". Then, change all occurrences of "sheep" to "goats". Last, change all occurrences of "foxes" to "sheep"

the variable age is to be used to represent a persons age in years. Which of the following is the most appropriate data type for age? a: string b: boolean c: number d: list

c: number

What is printed as a result of the following code segment? var1 = "toppings" var2 = "ice cream" print(var1 + var2) a: ice creamtoppings b: ice cream toppings c: toppingsice cream d: toppings ice cream

c: toppingsice cream

x <- 25 y <- 50 z <- 75 x <- y y <- z z <- x Which of the variables have the value 50 after executing the code segment? a: x only b: y only c: x and z only d: x, y and z

c: x and z only

With Python graphics, what are the coordinates of the bottom left corner? a: 0,0 b: get_width(), 0 c: get_width(), get_height() d: 0, get_height()

d: 0, get_height()

What is printed as a result of the following code segment? x = 9 + 6 / 3 * 2 - 1 print(x) a: 21.0 b: 9.0 c: 15.0 d: 12.0

d: 12.0

a <- 10 b <- 20 c <- 30 d <- 40 x <- 20 b <- x + b a <- x+1 d <- c+d/2 DISPLAY a DISPLAY b DISPLAY c DISPLAY d a: 10 20 30 40 b: 21 30 40 50 c: 21 40 30 40 d: 21 40 30 50

d: 21 40 30 50

Which of the following is NOT a legal variable name in Python? a: my_var_2 b: _2_my_var c: _my_var_2 d: 2_my_var

d: 2_my_var

A teacher has a goal of displaying the names of 2 students selected at random from a group of 30 students in a classroom. Any possible pair of students should be equally likely to be selected. Which of the following algorithms can be used to accomplish the teacher's goal? a: Step1: assign each student a unique integer from 1 to 30 step 2: generate a random odd integer n from 1 to 29 step 3: Select the student who is currently assigned integer n and display the students name step 4: generate a new random even integer n from 2 to 30 step 5: select the student who is currently assigned integer n and display the student's name b: Step1: assign each student a unique integer from 1 to 30 step 2: generate a random integer n from 1 to 15 step 3: Select the student who is currently assigned integer n and display the students name step 4: generate a new random even integer n from 16 to 30 step 5: select the student who is currently assigned integer n and display the student's name c: Step1: assign each student a unique integer from 1 to 30 step 2: generate a random integer n from 1 to 30 step 3: Select the student who is currently assigned integer n and display the students name step 4: generate a new random integer n from 1 to 30 step 5: select the student who is currently assigned integer n and display the student's name d: Step1: assign each student a unique integer from 1 to 30 step 2: generate a random integer n from 1 to 30 step 3: Select the student who is currently assigned integer n and display the students name step 4: The student who was selected in the previous step is assigned 0. All other students are reassigned a unique integer from 1 to 29 step 5: generate a new random integer n from 1 to 29 step 6: select the student who is currently assigned integer n and display the student's name

d: Step 1: assign each student a unique integer from 1 to 30 step 2: generate a random integer n from 1 to 30 step 3: Select the student who is currently assigned integer n and display the students name step 4: The student who was selected in the previous step is assigned 0. All other students are reassigned a unique integer from 1 to 29 step 5: generate a new random integer n from 1 to 29 step 6: select the student who is currently assigned integer n and display the student's name

A student is creating an algorithm to display the distance between the number num1 and num2 on a number line. The following table shows the distance for several different values value of num1: 5, 1, -3 value of num2: 2, 8, 4 distance between num1 and num2: 3, 7, 7 a: step 1: Take the absolute value of num1 and store it in the variable absNum1 step 2: Take the absolute value of num2 and store it in the variable absNum2 step 3: Subtract absNum1 from the absNum2 and display the result b: step 1: Take the absolute value of num1 and store it in the variable absNum1 step 2: Take the absolute value of num2 and store it in the variable absNum2 step 3: Add absNum1 and the absNum2 and display the result c: step 1: add num1 and num2 and store the result in the variable sum step 2: Take the absolute value of sum and display the result d: step 1: subtract num1 from num2 and store the result in the variable diff step 2: Take the absolute value of diff and display the result

d: step 1: subtract num1 from num2 and store the result in the variable diff step 2: Take the absolute value of diff and display the result

var1 <- "cat" var2 <- "dog" var3 <- "bird" var1 <- var2 var3 <- var1 var2 <- "fish" What is the value of var3 after the code executes? a: dog b: cat c: fish

dog


संबंधित स्टडी सेट्स

Music Appreciation 215 Chapter 16: Singing in Friendship- The Renaissance Madrigal

View Set

Lesson 8 Quiz 9 Social class in the US

View Set

Intro To Psych Exam 2 Quiz Reviews

View Set

A.D. Banker - Life Insurance Basics Ch. 14 Part 2

View Set