CP104 Lecture Notes - Lecture 3: Global Variable, Local Variable, Relational Operator

40 views4 pages
School
Course
Professor
Monday Oct 2 2017 midterm 3-4:30 sunday october 29
Condition statements (if else statements)
Readings 3.1-3.6
1) For each function we will write for a doc string
2) Triple quotations
3) Void function doesn’t return anything
4) A function must have one return value
Local variable/ arguments
- Variables created in the function can be only seen inside the function
-Variable changes inside- changes the copy not the original
Global variable
- defined outside the function
The function looks locally if no variable it looks globally ( outside the function)
- Global variable are not prefered
- Not going to be using global variables as much
- Overwrite values
EXAMPLE
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in
hayjayshay and 38575 others unlocked
CP104 Full Course Notes
2
CP104 Full Course Notes
Verified Note
2 documents

Document Summary

Readings 3. 1-3. 6: for each function we will write for a doc string, triple quotations, void function doesn"t return anything, a function must have one return value. Variables created in the function can be only seen inside the function. Variable changes inside- changes the copy not the original. The function looks locally if no variable it looks globally ( outside the function) Not going to be using global variables as much. Def tile_floor(room_w,room_len,tile_w, tile_1en): num_tile= (room_w//tile_w) * (room_len//tile_len)>>>> instead of getting floor division we use regular division and use the function ceil to round up ( so 4. 5 tiles counts as 5)>>>>> Tile_l = 1 result = tile_floor (room_w,room_len,tile_w, tile_len) print( for 10x 10 room by 1x1 tiles we need , result) Result = tile_floor(24,37,1. 5,1. 5) print( for24x 37 room by 1x1 tile we need , result) Midterm ( short answer question write what the code does) Monday oct 2 2017 midterm 3-4:30 sunday october 29 say_hello()

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents