1 / 19

Topics Covered So Far

Topics Covered So Far. Variables. int real boolean char const string. Simple formatting. put “this”:10, “is”:10 , “that”:10 -allots 10 character spaces for each element in quotation marks, whether they are strings or numbers put number1:10:2, number2:10:5

jaimie
Télécharger la présentation

Topics Covered So Far

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. Topics Covered So Far

  2. Variables • int • real • boolean • char • const • string

  3. Simple formatting put “this”:10, “is”:10 , “that”:10 -allots 10 character spaces for each element in quotation marks, whether they are strings or numbers put number1:10:2, number2:10:5 -allots 10 character spaces to each number and sets number1 to 2 decimal places and number 2 to 5 decimal places

  4. Repetition • Counted loops versus conditional loops • Variables declared within a loop only exist while the loop is executing • Counted (for) loops are more compact and have an automatic variable declared

  5. Counted loops for count : 1 .. 300 put “This will print “, count, “ times.” end for

  6. Conditional loops var number : int loop put "Please enter a number." get number exit when number = 10 end loop put "You just entered number 10."

  7. if - elsif Structure if length (word) < 4 then put "This word is less than 4 letters long" elsif length (word) < 8 then put "This word is less than 8 letters long" else put "You must be really really super smart!" put " Oh my, to know such a BIG word!" end if

  8. Pre-Built functions if length (choice) > 4 then X := Rand.Int (1, 10) randint (variable, 1, 10) var letter : char if ord(letter) > 10 and ord(letter) < 100 put “what kind of letter is that?” end if

  9. Combining Conditions exit when choice = "No" or choice = "no" or choice = "NO" if x > 4 and x < 8 then blah blah elsif x >8 and x < 100 or x < 0 blue blue blue elsif x = 8 Blum blum blum else put “what’s left over?” end if

  10. Concatenation string1 := character + string1(2..length(string1)) var word2 : string var word3: string word3 := string1 + word2

  11. ASCII

  12. ASCII Go To www.asciitable.com Go To www.asciitable.com ord (word (count)) will return an ASCII integer value for a char i.e., word := “hello” ord (word(5)) = 111 this would evaluate as true because the character “o” has an ASCII value of 111 (American Standard Code for Information Interchange)

  13. get skip Collects end of line markers before getting characters

  14. locate (10,20) put "Right Now" delay (1000) setscreen ("screen") var row, column, colr : int loop randint ( row, 1, maxrow - 1) randint ( column, 1, maxcol) randint (colr, 0, maxcolor) if row = 10 then row := 11 end if color (colr) locate (row, column ) put "*" .. % Use dot-dot to avoid clearing end of line end loop

  15. % locate % Syntax locate ( row, column : int ) % % Description The locate procedure is used to move the cursor % so that the next output from put will be at the % given row and column. Row 1 is the top of the screen % and column 1 is the left side of the screen. %

  16. % color % % Syntax color (Color : int) % % Description The color procedure is used to change the currently % active color. This is the color of characters that are % to be put on the screen. The alternate spelling is colour.

  17. setscreen % % setscreen ("graphics:300;100") % % This program outputs the square roots for the first 200 numbers. % The user can inspect all the output and print the values after % the program has finished execution % % setscreen ("text") % for value : 1 .. 200 % put value : 3, " ", sqrt (value) % end for % % This program creates a window without a button bar at the top that % is sized to fit the screen. It then draws an "X" in red in the window. % % setscreen ("graphics:max;max,nobuttonbar") % drawline (0, 0, maxx, maxy, red) % drawline (maxx, 0, 0, maxy, red)

  18. Turing Documentation can be found at http://compsci.ca/holtsoft/doc/

More Related