Intro To Programming Flashcards
function to print message
print()
location of code being ran (input)
code cell
computers response to code cell
output
annotating code
comments (#)
rules of variables
-cannot have spaces
-only include letters, numbers & underscores
-have to start with letter or variable
creates & assigns value to variable
=
a block of code designed to perform a specific task
function
what do functions do?
allow you to roughly same calculations multiple times without duplicating code
what is a header?
defines the name of the function and the argument
def
defines function
name of variable used as input to function
-enclosed in parentheses followed by colon ():
-appear immediately after the function name
argument (function can have none)
body of function
specifies work function does
-every line of code must be indented four spaces
-runs indented code from top to bottom
part of the code that is accessible
variable scope
local scope
variables defined inside a function that cannot be accessed outside of that specific function
global scope
variables defined outside all functions; can be accessed anywhere
rules when adding multiple arguments
-add inside parentheses
- separate with comma (same with inputted values)
can a functions argument be empty?
yes
numbers withOUT any fractional part
integers
-can be positive or negative (or 0)
floats
numbers with fractional parts
-can have many numbers after decimal
-can also be specified with fraction
-numbers with decimal points automatically recognized as float
round() {function}
allows you to round a function a specific number of decimal places
represent True or False
Booleans
not True
False
not False
True
collection of characters (alphabet letters, punctuation, numerical digits or symbols) contained in quotation marks
strings (commonly used to represent text)