Section 1

Preview this deck

How do you format a dictionary?

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

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (35)

Section 1

(35 cards)

How do you format a dictionary?

Front

d = {'key1': 1, 'key2' : 2}

Back

What is a key?

Front

Any string or number

Back

How do you write equals in python?

Front

==

Back

What is an example of a comparator?

Front

3<4 5>= 5 10==10 12 != 13

Back

How would you import a single function?

Front

from (module) import function

Back

If you want to make sure an equation is based off a specific module, what should you write?

Front

module.name

Back

What can you use ".append()" for?

Front

To add a variable or string to a list

Back

How do you do exponents in Python?

Front

"*" (Ex. 10 * 2 = 100)

Back

How do you represent an empty dictionary?

Front

{}

Back

How do you format a conditional statement?

Front

example: def variable() if 6 > 7: print "False" elif 6 < 7: print "True" else: print "Coding is a lot of work" print variable()

Back

What is a float?

Front

A number with decimals

Back

What is a string?

Front

a list of characters

Back

How do you write a function?

Front

def _(name)__ ():

Back

How do you do multiplication?division? addition? subtraction?

Front

*,/,+,-

Back

Should the body always be indented?

Front

yes

Back

What is a datatype?

Front

A way to store a collection of different pieces of information.

Back

What are some datatype examples?

Front

Strings, numbers, and booleans.

Back

How do you format a for loop?

Front

for variable in list_name

Back

What is a boolean?

Front

Similar to variable, but only be a true or false.

Back

What is a variable?

Front

A way to store a specific piece of data and gives it a specific name.

Back

How can you write multiple lines of comments in Python?

Front

Using triple quotation marks.

Back

What is an example of a boolean operator?

Front

3 < 4 is True

Back

What does a modulo show? How do you pull it up?

Front

Remainders when doing division. Pulled up by using "%" (ex. (3%2) will give a modulo of 1).

Back

What is an index?

Front

An address that identifies the item's place in the list. l

Back

def power(base,exponent): result = base**exponent print "%d to the power of %d is %d." % (base, exponent, result)

Front

This is an example of setting up a function. Keep in mind that the result and print tap should be indented four lines when writing code.

Back

How do you express a list?

Front

list_name=["item_1", "item_2"] or list_name[index]

Back

What will maximum=max(1,2,3) return if you write print maximum?

Front

3

Back

What number do list indices begin with?

Front

0 (NOT 1)

Back

How do you call up a key in a dictionary?

Front

print (dictionary name)['key']

Back

What is a module?

Front

A file that contains definitions that can include variables and functions

Back

How would you import everything from a module?

Front

from (module) import *

Back

What can a string contain?

Front

Letters, numbers, and symbols

Back

What does != mean ?

Front

Checks if value of two operands are equal or not and if they are not, it makes the condition true (ex. a != b is true)

Back

How do we import a module?

Front

using 'import'

Back

What do you do when you have an apostrophe?

Front

Use a backslash "\"

Back