1 / 17

Student objective: How are variables set up and used in programming?

Student objective: How are variables set up and used in programming?. Bell ringer: Where we using python in the interactive mode or script mode on Friday?. Set Up Grade Sheet. KWL (5) Syllabus (5) Communication compact (5 ) Computer Parts Project (25) Vocab (10) Print Project ( 10 )

miyo
Download Presentation

Student objective: How are variables set up and used in programming?

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. Student objective: How are variables set up and used in programming? Bell ringer: Where we using python in the interactive mode or script mode on Friday?

  2. Set Up Grade Sheet • KWL (5) • Syllabus (5) • Communication compact (5) • Computer Parts Project (25) • Vocab (10) • Print Project (10) • Number Guessing Game (10)

  3. Agenda • Notes on python basics and variables • Assignments: programming

  4. Bell Ringer Answer: Interactive Interactive mode-program and run in IDLE • Immediate feedback • Not designed to save and run later Script Mode Write the program • Write program and save it to use later

  5. Let’s try it • To write a python program and save it: • Open Python IDLE • Click on file—New Window • Type your program in • File—Save as .pyin documents folder of python • Click Run—Run Module • IDLE pops back up with program

  6. Syntax Errors • Spelling/grammar • Picked up prior to running program

  7. Runtime errors • Occur during execution of program • 4-line error message starting with Traceback • Tells where the error is and what it is

  8. Semantic errors • Don’t use commas with numbers or will get this error • Code will run but be wrong

  9. Computer • Input • Processing • Output

  10. Variables Variables (values) • Integers: int numbers no decimal points • Strings: str use singleor double quotation character or string of characters: letters, numbers, punctuation • Long string: str multi-line string: triple quotes • Floating point: float decimal numbers

  11. Color coding • Special words, like print: orange • Strings: green • Output: blue • Comments: red

  12. Comments • Used to explain code • Invaluable to programmers • Are not executable by the computer • # symbol is used to denote the start of a comment

  13. Blank Lines and Spacing Blank lines • Are ignored by the computer • Can make program easier to read Spacing • is critical and will create errors if not followed • Tells where blocks of code start and where they stop • Convention: 4 spaces in • Necessary for if statement

  14. Naming Variables • If you don’t know the type of variable, you can find out by • Writing in the IDLE: • type ( variable ) then click return (Remember strings in quotes, numbers not) • You can name variables (words, numbers) to input into memory (Name it so you can use it) • Teacher = “Mr. Morton” • First = 5 • *You can have more than one name for one thing • *You can also change names

  15. Rules for naming variables: • Can use letters, numbers and underscore character(_) • Case sensitive • Must start with letter or underscore (Not a good idea to start with underscore), NOT A NUMBER • Make variables names clear—don’t try to abbreviate

  16. Concatenate: • Adding strings like “cat” + “dog” • Results would be catdog

  17. Using variables • Variables can also be made to equal themselves: • >>Score = 7 • >>Score = Score • >>Score = Score + 1 • >>print Score Hit return • Generates >>8 • Useful to increment or decrement a value

More Related