

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
Computer Science Study Guide Questions with Correct
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


What is an algorithm? - ANSWERSAn algorithm is a set of clear steps aimed to accomplish a task in a given period of time. What are the 4 main characteristics of an algorithm? - ANSWERS(1) You can number its steps in a specific order. (2) Each instruction is clear and do-able. (3) It accomplishes a task or solves a given problem. (4) It terminates (does not run forever!) What are the 4 ways you can represent an algorithm? - ANSWERS(1) Natural Language (English, French, Spanish). (2) Flowchart (shapes). (3) Pseudo-code (code- like formatted english constructs). (4) Programming Languages (real executable code on the computer, like Python, Alice, Java, etc). What is a sequence? - ANSWERSIt is a set of instructions that are executed in the order they appear (like, open closet door > take all clothes > put on bed). What is a conditional operation? - ANSWERSIt is a "decision making" code construct that asks a true/false question and then selects the next instruction based on the answer to that question. What is a repetitive operation? - ANSWERSIt is code construct that repeats the a block of instructions (a loop). What shape should you always begin and end your flowcharts? - ANSWERSAn oval. What shape should you use for steps like "Drive a mile", or "Calculate the average"? How many arrows can come out of that shape? - ANSWERSA rectangle, since they are actions/verbs. One arrow coming OUT only! What shape do you use for a question/condition? How many arrows can come out of that shape? - ANSWERSA rhombus. Exactly two arrows coming OUT: one for the Yes/True answer, and one for the No/False answer. How do you create a loop in a flowchart? Example, if you want to work until it is 5pm then go home, how can you represent that in a flowchart? - ANSWERSYou need to use a rectangle for the action ("work") followed by rhombus to check for the condition ("Is it 5pm?"). The "No" arrow will point back to the rectangle ("work"), and the other arrow (Yes) will point forward to the next instruction ("go home").
In pseudo-code, if x is set to 10, what will the instruction "x = x + 5" do? - ANSWERSIt will change the value of the variable x from 10 to 10+5 which is 15. What are the keywords for the IF statement? - ANSWERSIF, THEN, ELSE, ENDIF. Make sure to indent the steps inside the IF and the ELSE blocks, and to align the IF with the corresponding ELSE and ENDIF. What are the keywords for the WHILE statement? - ANSWERSWHILE, ENDWHILE. Make sure to indent the steps inside the while block. How many times does an IF-ELSE statement execute? - ANSWERSOnce. How many times does a WHILE execute? - ANSWERSIt can run multiple times, as long as the condition is still true. What does this code print? (1) x = 10 (2) IF x > 5 THEN (3)print "A" (4)ELSE (5)print "B" (6)ENDIF - ANSWERSIt will print "A" since 10 is bigger than 5. What does this code print? (1) x = 10 (2) WHILE x > 5 (3) print x (4) x = x - 2 (5) ENDWHILE - ANSWERSIt will print "10", then "8", then "6". It stops after that since once x turns to 4, it no longer is bigger than 5, so the loop will stop repeating. Can you have an IF statement inside another construct? - ANSWERSYES!! You can write an IF statement inside another IF block or ELSE block, or inside a WHILE loop. The opposite is also true. You can put a WHILE inside an IF or ELSE block.