1/21
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
terminal
way to use computer from far (used in 60-70s)
Gives screen, keyboard and connection to computer/what actually using
Not actual computer
command line/prompt
text based interface for giving machine commands
shell
interpreter → the program that interprets the text as a command to the computer
Ex: powershell
Bash = born again shell
Zsh → z shell
tuple
fixed list → once u create list u cannot change it
Use ()
Is immutable
list
denoted by []
Is mutable → can change/edit once made
array
Index for lists start at 0
Ex: like u want to see something in list and get 1st item the position is 0
Can also start right to left at -1
Ex: in hello[-1] → returns ‘o’
float
floating point (number type) →decimal
Ex: 3.4
string
for text
Can wrap text in single or double quotes (‘ ‘ or “”)
Choose 1 & be consistent
*args
the asterisk is specific character that can go in front of 1 variable in a functions definition → should come after all of required/keyword arguments & is tuple that can capture extra inputs to the function
This allows for optional arguments that are variable in length → thing of a sum function
Usually used as “args but can replace variable name “args” with anything u want
**kwargs
Also allows for variable # of keyword inputs
“ ** ” can be put in front of any variable name but kwargs is usually used
Think of like user of function being able to input their own variable/inputs
function
(also called “method”)
is a transaction between input & output.
Can hv no input, 1 input, many, etc
Input can be named or not
Can be optional or required
def firstfunction ():
Pass (code)
global variable
can be seen anywhere in program
local variable
only seen in their local context
ex: ???
conditionals (if/elif/else)
Words in language that allow parts of programs to run depending on the conditions
full syntex:
#Check boolean statement
If <statement is true>:
#code block
Elif <another statement> is True:
# check other boolean
<code block>
pass
throw away word (used in functions) to make grammar checker happy & is for things not finished yet
Makes python interpreter happy
block
collection of code meant to be group tg
Specified with white space
Python is very sensitive to white space and spaces → bx space = grouping of code
for loop
goes for some fixed number of times
Ex: “do something for each item in list” or “do this 10 times”
while loop
executes block of code as long as some condition is true
If accidentally create infinite loop (neverending) → Click Ctrl C
This will interrupt and stop loop
range type
Behaves like list where values are same as indices
Bc can save space & doesnt need to store all the values
Saves current value, update value & stop value
full form of range
range(start, stop, step)
Start value default is 0
Stop value required
Step rule default is “+1”
comprehension
where creating collection where starts off empty & populate it w a for loop
Can take at least 3 lines of code & compress this into a single line (of code)
add example code
word "enumerate"
will return 2 things about a list/tuple → index & value
used to get both the index & value at the same time