Section 1

Preview this deck

If you already have a variable defined by you want to add more to it later in the code how do it?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

6

All-time users

6

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (67)

Section 1

(50 cards)

If you already have a variable defined by you want to add more to it later in the code how do it?

Front

Variable +=

Back

What do you need to remember about comparing values

Front

Comparing a string and integer value will be false

Back

What are writing function statements useful for?

Front

When you're waiting on an input for a variable from the user

Back

What do you need to remember about using the print function?

Front

1. Use lowercase for p 2. You can use single or double quotes to enclose a string Ex: print ('sanah') Print ("sanah") are equally valid

Back

How do we just get the remainder in a division problem?

Front

%

Back

How do you get a program to ignore a program: make a commment

Front

Anything written after # is ignored

Back

Keyword arguments:

Front

1. Define a variable in the function at the same time you define the function

Back

What is not a boolean statement?

Front

An opinion statement: "Cats are the best pets"

Back

What gets printed first

Front

"This is your desktop gets printed first"

Back

Return stuff*num_repeats

Front

If stuff = "row" and num_repeats = 3 then it will print Row Row Row

Back

Boolean Variables

Front

Giving a variable a true or false value by: A. Direct assignment or B. Setting it equal to a Boolean expression

Back

Boolean Expressions

Front

a statement that could be true or false

Back

How do string together different variables

Front

1. Print ( variable 1, variable 2, variable 3) 2. Message = variable 1 + variable 2 + " space " + variable3

Back

How do you add variables to functions?

Front

Def function_name (variable_name):

Back

How do you put a number in a print with numbers and strings?

Front

Str(variable_name)

Back

What are the rules for creating a variable?

Front

1. No spaces only "_" 2. Use = after variable 3. Enclose strings in "fish" (The red is the variable)

Back

If you want to run a function then,

Front

Do print (function (number))

Back

Three ways to string together

Front

1. Print (var1, "string", str(number_variable)) 2. Message = var1 + var2 + "string" 3. Return last_name + "," + first_name

Back

Is this a boolean statement? "Sunday starts with the letter "C"?

Front

Yes- even though it's always false

Back

How do you call a function after it's been defined? WHAT DO YOU NEED TO REMEMBER?

Front

Function_name () - don't leave in preceding space for the function

Back

What's the purpose of return

Front

Return permanently assigns those variables those quantities when a function is run, so that those variables return their values outside the function

Back

What's the problems with stats.mode?

Front

It only gives the smallest mode value `

Back

How do you do computations

Front

Print (number * number)

Back

How do you take the square root of something using exponents

Front

Raise it to the power of 0.5

Back

Can we use a formal parameter outside the function

Front

NO! It's outside the scope of it's definition

Back

Returning a string

Front

Back

How do you print strings and variables together and watch out for spaces

Front

1. STRINGS AND VARIABLES: print ("string" + variable) 2. Watch out for spaces by just putting a space in between the quotes

Back

Exponents in python

Front

Use the notation: **

Back

Front

Back

We have multiple lines of strings that we want to call again and again. How do we make it easier?

Front

Use functions

Back

You want to put a bunch of lines of string to be printed how do you ensure no confusion with the quotes and stuff

Front

Use three double or single quotes and don't forget equal sign after the variable

Back

Floating point number

Front

Decimal number

Back

How do you find the mode of a data set?

Front

1. From scripy import stats 2. Example_array = np.array([24,25,26,27,63)] 3. Example_mode = stats.mode(example_array)

Back

Return doesn't use what And functions definitely have what?

Front

Functions defining have a colon And return doesn't have an =

Back

Strings

Front

Blocks of text

Back

Output a list of phrases

Front

Print ()

Back

How to run multiple formal parameters

Front

Separate by comma

Back

How do you check if two values are not equal to each other

Front

<<< "7" != 7 True

Back

How do you check if two values equal each other

Front

<<< 7==7

Back

What is return useful for?

Front

It gives you the output of adding together multiple variables, BUT return doesn't print so you have to do print (function (x,y)).

Back

When do you define the formal parameter?

Front

When you run the function

Back

When you call back your function remember

Front

To put quotes around string

Back

Name Error

Front

1. Python sees a word it doesn't recognize 2. Look like a variable but wasn't defined * forgot to put quotes around a string

Back

Formal parameter

Front

Goes in the parenthesis of a function

Back

What is return? Returning multiple variables

Front

1. It prints and gives the variable it's new value permanently Return variable_name/5

Back

How do we give a variable name to the outputs of a function

Front

Back

How to find the median of an array?

Front

Variable1 = np.median (variable2), where variable 2 = array of numbers

Back

What do you need to remember about keyword arguments?

Front

Once you've given a variable a default value, then it cannot be a followed by another variable used by positionally

Back

How do you define a function

Front

Def loading_screen (): "Def" + variable_name + parenthesis + ":"

Back

Write a function that gives the square root of variable num

Front

Back

Section 2

(17 cards)

How would you take the average of a large data set of numbers?

Front

1. Write a variable equal to an array of numbers 2. Create another variable (V2) equal to the average of that variable 3. Print (V2)

Back

When conditions are not met then do this: syntax

Front

Else: NOTE SPACING

Back

Front

Back

Using a Boolean operator with variables

Front

Variable = ( 2+2=4) and (-1 * -1 <0) — only time you use parenthesis

Back

How do you check if a variable is a Boolean expression or a string?

Front

Back

What do you need to remember about writing Boolean expressions?

Front

Make sure your entire variable is in parenthesis

Back

"Not" Boolean operator

Front

Gives you the opposite T/F value

Back

Assigning Boolean Operator to variable

Front

Back

What's wrong with this piece of code?

Front

If then statements require double ==

Back

Other Boolean expressions

Front

Back

Boolean Operators

Front

And Or Not Else

Back

How do you write a condition statement

Front

If variable: Where ":" = then

Back

Try/ except

Front

Back

elif statement

Front

Will stop the code once that true statement is reached —-> Useful if you want to print one message

Back

What's wrong with this piece of code

Front

It's missing a colon

Back

Boolean Operators in action

Front

Back

What do you have to remember about direct assaignment for Boolean Variables?

Front

True/ False must be capitalized

Back