



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A series of questions and answers related to scripting and programming foundations. It covers topics such as operators, data types, variable declarations, expressions, functions, and control structures like loops and conditional statements. The questions are designed to assess understanding of basic programming concepts and problem-solving skills. It is useful for students preparing for exams or quizzes in introductory programming courses. This resource provides a concise review of fundamental programming principles, making it a valuable tool for reinforcing key concepts and improving exam readiness. The content is structured to facilitate quick review and self-assessment, enhancing learning outcomes and confidence in programming skills. It serves as a practical guide for mastering essential programming concepts through targeted practice and review.
Typology: Exams
1 / 35
This page cannot be seen from the preview
Don't miss anything!




























Which operator should be used to determine if a number is evenly divisible by 5? A + B - C * D % - correct answers ✅% A car drove 200 miles using 10 gallons of fuel. Which operation should be used to compute the miles per gallon, which is 20? A Addition B Subtraction C Multiplication D Division - correct answers ✅Division A variable should hold a person's height in meters. Which data type should the variable be?
A Integer B Float C String D Boolean - correct answers ✅Float A variable should hold the names of all past U.S. presidents. Which data type should the variable be? A Integer array B Float array C String array D Boolean array - correct answers ✅String Array A program uses the number of seconds in a minute in various calculations. How should the item that holds the number of seconds in a minute be declared? A Constant float userTime
7 7.5 - correct answers ✅6. Given float x = 10.2 and float y = 1.0. What is the value of the expression x / y? A 0. B 1. C 10 D 10.2 - correct answers ✅10. What kind of operator is the == in the expression i == 20? A Assignment B Arithmetic C Equality D Logical - correct answers ✅Equality
What is the purpose of parentheses () in a programming expression? A To print expressions B To group expressions C To run expressions D To compose expressions - correct answers ✅To group expressions Given float x = 3.0. Which expression evaluates to 2.0? A x / 3 * 2 + 2 B x - 2/ C x + 0.5 / D x / 2 + 0.5 /2 + .25 - correct answers ✅D Which expression evaluates to true only when the user is within 3 years of 21 years, given a variable x containing a user's age? A x >= 18) or ( x <= 24)
A function should convert hours and minutes to seconds, such as converting 1 hour and 10 minutes to 4,200 seconds. What should be the input to the function? A Hours only B Minutes only C Hours and minutes D Hours, minutes, and seconds - correct answers ✅C A function returns a number x cubed. For example, if x is 3, the function returns 3 * 3 * 3, or 27. What should be the input to the function? A x B x, x C x, x, x D 27 - correct answers ✅A A function calculates the weight difference (Diff) given two sample weights (S1 and S2).
What should be the output from the function? A S1 only B S2 only C S1 and S D Diff - correct answers ✅D function P(integer x) returns integer y y = 2 * x What does P(5) evaluate to? A 2 B 5 C 10 D 25 - correct answers ✅C Function F() Put "Hey" to output
What is the return value of a function? A Output of a function B Call to run the function C Data passed to the function D Variable in the declaration of the function - correct answers ✅A A program should continue accepting input numbers, adding each to a sum, until a 0 is input. Which control structure should be used? A If statement B For loop C Multiple if statements D While loop - correct answers ✅D Joe is building an online game. He wants to provide a riddle and have the player guess the answer. The game needs to prompt the user to enter the answer, check to see if it the
input provided does not match the correct answer, and continue prompting the user until the answer entered matches the correct answer. Which control structure supports Joe's needs? A For loop B While loop C Do-while loop D If-else branch - correct answers ✅C What is put to output by the following pseudocode? x = 3 do Put x to output Put " " to output x = x - 1 while x > 0 A 3 2 1 0
while i < 20 Put i to output i = i + 1 A i B i<20 /> C i = 0 D i = i + 1 - correct answers ✅B What is the loop variable initialization in the following pseudocode? y = 0 s = 100. while y < 10 s = s + (s * 5.0) y = y + 1 A y = 0
B y = y + 1 C s = 100. D s = s + ( s * 5.0) - correct answers ✅A Order the steps needed to output the minimum of x and y from first (1) to last (4). Select your answers from the pull-down list. A Declare variable min B Put min to output C min = x D If y < min, set min = y - correct answers ✅ACDB Order the steps needed to calculate speed in miles per hour given a start and end location and time traveled in hours from first (1) to last (4). Select your answers from the pull-down list. A Put speedMph to output
A Whether x and y are the same B Whether x and y are negative C Whether x is 1 D Whether x is 0 - correct answers ✅A What does the following algorithm accomplish? x = Get next input if x == - Put "Goodbye" to output A Outputs -1 when user types any input B Outputs "x" when user types - C Outputs -1 when x is positive D Outputs Goodbye when user types -1 - correct answers ✅D
What does an output of 1 indicate for the following algorithm running on a five-element list of integers? i = 0 x = 0 while i < 5 if list[i] < 0 x = 1 i = i + 1 Put x to output A All integers are positive. B All integers are negative. C At least one integer is negative. D At least one integer is positive. - correct answers ✅C When should a programmer develop an algorithm to solve a problem?
An algorithm should output "OK" if a list's numbers are all non-zero, else the output is "Not OK." Which test is a valid test of the algorithm? A Input 0, 0, 0. Ensure output is "OK." B Input 5, 4, 0. Ensure output is "OK." C Input -3, -2, 5. Ensure output is "Not OK." D Input 99, 0, 5. Ensure output is "Not OK." - correct answers ✅D What is put to output by the following flowchart, if the input is 17? A Too young B OK C Too old D Nothing is put to output. - correct answers ✅B
What is put to output by the following flowchart, if the input is 3 5 -1? A 3 5 - B 3 5 C 6 10 D 6 10 -2 - correct answers ✅C What is the purpose of the following class diagram? A Shows how the Employee class is used in the program B Describes the execution flow of the Employee class' operations C Specifies the Employee class' behavioral requirements D Depicts the Employee class' name, data members, and functions - correct answers ✅D