Intro To Programming Flashcards

1
Q

function to print message

A

print()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

location of code being ran (input)

A

code cell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

computers response to code cell

A

output

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

annotating code

A

comments (#)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

rules of variables

A

-cannot have spaces
-only include letters, numbers & underscores
-have to start with letter or variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

creates & assigns value to variable

A

=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

a block of code designed to perform a specific task

A

function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what do functions do?

A

allow you to roughly same calculations multiple times without duplicating code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a header?

A

defines the name of the function and the argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

def

A

defines function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

name of variable used as input to function
-enclosed in parentheses followed by colon ():
-appear immediately after the function name

A

argument (function can have none)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

body of function

A

specifies work function does
-every line of code must be indented four spaces
-runs indented code from top to bottom

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

part of the code that is accessible

A

variable scope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

local scope

A

variables defined inside a function that cannot be accessed outside of that specific function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

global scope

A

variables defined outside all functions; can be accessed anywhere

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

rules when adding multiple arguments

A

-add inside parentheses
- separate with comma (same with inputted values)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

can a functions argument be empty?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

numbers withOUT any fractional part

A

integers
-can be positive or negative (or 0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

floats

A

numbers with fractional parts
-can have many numbers after decimal
-can also be specified with fraction
-numbers with decimal points automatically recognized as float

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

round() {function}

A

allows you to round a function a specific number of decimal places

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

represent True or False

A

Booleans

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

not True

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

not False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

collection of characters (alphabet letters, punctuation, numerical digits or symbols) contained in quotation marks

A

strings (commonly used to represent text)

25
returns length of string (includes space, comma&exclamation mark) does not include quotation marks
len()
26
length of empty string
0
27
changes number (float/integer) to string
incase in " "
28
changing string of numbers to float
float()
29
adding strings "abc"+"def"
concentrates them abcdef (not possible to subtract or divide two strings)
30
multiplying string by integer "abc" * 3
results in original string concentrated with itself a specified number of times abcabcabc (cannot multiply string by float!)
31
statements that are either True or False ; used to make decisions
Conditions (2>3)
32
checking if var_one is less than 1, and if var_two is greater than or equal to var_one-- what is output? var_one = 1 var_two = 2 print(var_one < 1) print(var_two >= var one)
False True
33
conditional statements
Instructions that perform different actions based on wether a condition is true or false
34
rules to "if" indentation
-two levels > 1st level is always needed to indent code block inside a function > second level needed to indent code block belonging to "if" statement
35
if...else
If (conditional statement): checks if condition is true and execute a block of code if it is Else (conditional statement): provides alternative action if condition is false
36
conditional statement used to check if multiple conditions are true -'the previous condition was false, so lets check if this new condition might be true.'
if... elif... else --if conditionals in 'if' and 'elif' statements both evaluates to False, code block inside 'else' statement is executed
37
always rounded up to closest integer
negative floats
38
always rounded down to closest integer
positive floats
39
multiplying integer or float by boolean with value of True:
returns same integer or float and is equivalent to multiplying by 1
40
multiplying integer or float by boolean with value of False
ALWAYS returns 0 -true for both positive and negative numbers
41
multiply string by boolean with value of True
returns same string
42
multiply string by boolean with value of False
returns empty string (length of 0)
43
lists, sets, dictionaries & tuples
datasets available for holding data
44
creating a list
enclose items in [ ] and separate each item with a comma -each item enclosed in quotation marks(string)
45
printing length of list (number of entries)
len( ) -name of list in parentheses
46
referring to an item in a list by its position ( first, second, third..)
indexing
47
rules to pythons zero-based indexing
-to pull first list, use 0 -pulling second entry in list, use 1 -pull final entry, use one less than original length of list
48
pulling a segment of a list (ex: first three or last two entries)
slicing -pull FIRST x enteries, [:x] -pull LAST y, [-y:]
49
removing items from list
.remove( ) -item wish to remove within parentheses
50
adding items to list
.append( ) -item wish to add in parentheses
51
minimum of list
min( )
52
maximum of list
max( )
53
sum( )
adds every item in list -can do similar calculations with slices of list
54
(sum(hardcover_sales[:5])/5 )
sum of first five days and divide by 5 (total number books sold in five days)
55
turning string into list uses what function
.split( ) - enclosed in ' ' in parentheses: character marking end of list item and beginning of another ex: print(flowers.split(","))
56
allow creation of lists from values in another list
list comprehensions
57
Pulling first three entries from list
[:3]
58
Pulling last five entries from list
[-5:]