1 / 17

TIK 2O - Test #3

TIK 2O - Test #3. Loops, Debugging, Functions, Arrays, Software Development Process. Multiple Choice. D – infinite loop (K doesn’t change) 69% D – Until stops when condition becomes true 69% C – rectangle (x coordinate changes by 2, y coordinate changes by 3) 69%

khoi
Download Presentation

TIK 2O - Test #3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TIK 2O - Test #3 Loops, Debugging, Functions, Arrays, Software Development Process

  2. Multiple Choice • D – infinite loop (K doesn’t change) 69% • D – Until stops when condition becomes true 69% • C – rectangle (x coordinate changes by 2, y coordinate changes by 3) 69% • D Max + 1 – include 0 50% • Sum  Sum = Sum + Item (sum is incremented every time) 85% • B Item  beside the For 85%

  3. Multiple Choice (Con’t) • B – Integer  vbYes and vbNo represent numerical integer values 46% • C – runtime error  the error doesn’t happen until the input is entered 81% • A – logic error – it creates the variable, so you won’t know unless the output is incorrect 54% • C – diagonal – both x and y change 77%

  4. Multiple Choice (Con’t) • A – used to identify the array element 77% • C – control arrays start with an index of 0 92% • A – 2  one for the checkboxes, and one for the command buttons 100% • A – Problem Analysis – clarify the problem 85% • A – using price(1) whole time – first element … last value it is assigned is 20 69%

  5. Multiple Choice (Con’t) • A – if the condition is met, it will not go inside the loop at all 77% • B – false – if a step is used, you can have it increment or decrement by whatever you want 69% • B – it has four elements  9, 10, 11, 12 92% • A – their index is different, but the name is exactly the same 81% • B – you are planning the major logic of your code as well as the comments 73%

  6. Short Answer #1 (KU) Explain the difference between a conditional loop and a counted loop. 1 mark – conditional may execute any number of times – until / while a condition is being met 1 mark – counted loops execute a fixed number of times

  7. Short Answer #2 (KU) What is a function? 1 mark - predefined section of code (the code is already created for you, we just use it) 1 mark - it performs a specific task (like rounding a number, or creating a random number)

  8. Short Answer #3 (KU) Explain what is included in the Design – User’s Perspective of the Software Development Process 1 mark – sketch of the form 1 mark – description of program flow 1 mark – in simple, non technical language – anybody should be able to understand

  9. Short Answer #4 (App) Do While not (a <> b) {statements} Loop Rewrite the following loop so that it’s meaning is the same, but it is logically simpler. Do While a = b {statements} Loop Do Until a <> b {statements} Loop

  10. Short Answer #5 (App) Rewrite the following as a conditional loop 1 mark – initialize x 1 mark – proper condition 1 mark – increment x by 2 1 mark – proper order of statements For X = 10 to 20 Step 2 Total = Total + X + Y / 2 Next X X = 10 Do While X <= 20 Total = Total + X + Y / 2 X = X + 2 Loop

  11. Short Answer #6 (App) What is the output of the following statements? 1 mark – calculate Vals(3) properly = 7 Vals(1) + 1 + Vals(2 – 1) =3 + 1 + Vals(1) = 3 + 1 + 3 = 7 1 mark – correct output - same line 3 4 7

  12. Short Answer #7 (App) Write VB statements that would exchange the first and last elements of a Numbers array that has the following declaration. Dim Numbers (1 to 100) as Integer 1 mark – using only one temp variable 1 mark – properly switches Temp = Numbers(1) Numbers(1) = Numbers(100) Numbers(100) = Temp

  13. Short Answer #8 (App) Trace the following code segment and sketch the output on a form. X = 1 Y = 5 Total = 0 Do Print “Loop 1” Y = Y – 2 Do While X < Y Print “Loop 2” Total = X * Y X = X + 1 Loop Loop While Y > 0 Print X; Y; Total;

  14. Short Answer #8 (App) Trace the following code segment and sketch the output on a form. X = 1 Y = 5 Total = 0 Do Print “Loop 1” Y = Y – 2 Do While X < Y Print “Loop 2” Total = X * Y X = X + 1 Loop Loop While Y > 0 Print X; Y; Total; Loop 1 Loop 2 Loop 2 Loop 1 Loop 1 3 -1 6

  15. Short Answer # 9 (TI) Explain how a control array could be used to simplify the following code segment. 1 mark – identifying that it is used for imgPic1, imgPic2, etc. 1 mark – use the random number as the index for the new imgPic(index) array 1 mark – random number needs to be 0 to 4, or use num – 1 as the index 1 mark – changes the code to 2 lines in length Num = Int((Rnd(5 – 1) + 1) imgGraphic.picture = imgPic(num-1).picture

  16. Code Writing #1 1 mark – variable declarations 1 mark – initialize variable (for loop does this on its own) 1 mark – proper loop 1 mark – correct circles 1 mark – use scaleheight and scalewidth 1 mark – only use one loop Dim midx as Integer Dim midy as Integer Dim coordinate as Integer Coordinate = 0 Midx = me.scalewidth/2 Midy = me.scaleheight/2 Do until coordinate >= me.scaleheight circle (coordinate, midy), 0.5 circle (midx, coordinate), 0.5 coordinate = coordinate + 1 Loop

  17. 1 mark – variable declarations (Average = single) 2 marks – use loop to calculate total and therefore average 2 marks – loop to count the number of students that are above average 1 mark – output (in statement form) 1 mark – initialize accumulator variables Code Writing #2 Dim x as Integer Dim total as Single Dim average as Single Dim Counter as Integer total = 0 For x = 1 to numstudent total = total + marks(x) Next x average = total / numstudent counter = 0 For x = 1 to numstudent if marks(x) > average then counter = counter + 1 end if Next x Print “There are “; counter; “students with a mark above average”

More Related