Python Flashcards
How do you print an entire array?
for n in #data name#:
print(str(n));
How about length of an array
len(##data name))
What is a function and what should I know about?
this is a function
def <name>(<variable name)</name>
with a bunch of math or conditions after indented.
for example
def get_pay(num_hours):
receiving $15/hour
pay_pretax = num_hours * 15
pay_aftertax = pay_pretax * (1 - .12)
return pay_aftertax
Now if I want to recall it, I just do get_pay(40) for eg.
Note: you cannot refer to the variable within the function body.
Why should I use a function with no argument?
If you don’t want a dynamic function and want to show the same answer over and over without having to type it, you can use function with no argument.
for example
def greeting_message()
print(“Hello”)
print(“How are you?”).
now every time you greeting_message()
it will print the message.
What are the symbols used in a conditional statement (if, elif…)?
Symbol Meaning
== : equal
!= : does not equal
< : less than
<= less and equal than
> : greater than
> = greater and equal than