Section 1

Preview this deck

What's an important maintainability feature of Python lists?

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

1

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (42)

Section 1

(42 cards)

What's an important maintainability feature of Python lists?

Front

You can use a comma after the last element and before the closing bracket, like this: [a, b, c, d,]

Back

How do you return a list of bytes objects from d = b'some bytes'?

Front

d.split(), which produces [b'some', b'bytes']

Back

How do you write 3*10^8 in Python?

Front

3e8

Back

How do you write a for loop in Python?

Front

for item in iterable: ...body...

Back

How do you decode a byte object data into a string and then split that string into a list of individual words?

Front

data.decode('utf-8').split()

Back

How do you escape a quotation mark in a string?

Front

\"

Back

How do you encode raw binary data or fixed-width, single character encodings like ASCII?

Front

b" or b'

Back

How do you decrement c by 1?

Front

c -= 1

Back

What happens when you make a calculation including both int and float numbers?

Front

The result is promoted to a float

Back

How do you delimit literal lists?

Front

[ a, b, c], with the items within the list separated by commas

Back

How do you create a value prompted from a user input?

Front

input()

Back

How do you increment c by 1?

Front

c += 1

Back

How do you append 1.68 to the end of list b?

Front

b.append(1.68)

Back

Given a number with a decimal point, how does Python interpret its type?

Front

As a float

Back

How do you break out of a loop with an early exit?

Front

break

Back

What is the Python relational operator for value equality?

Front

==

Back

How does Python represent a null value?

Front

None

Back

How do you create the special floating point value nan ('not a number')?

Front

float("nan")

Back

How do you construct a list of characters from the string "characters"?

Front

list("characters")

Back

How do you pull the fifth character from the string s = 'parrot'?

Front

s[4]

Back

How do you create a WYSIWYG raw string?

Front

r" or r'

Back

How do you assign an empty list to b?

Front

b = []

Back

How do you delimit multi-line strings?

Front

""" or '''

Back

How do you interrupt infinite loops?

Front

Ctrl-C

Back

How do you return a capitalized version of the string c = 'oslo'?

Front

c.capitalize()

Back

How do you create an empty dictionary e?

Front

e = {}

Back

How do you assign a string 'lol' to a key 'alice' in dictionary d?

Front

d['alice'] = 'lol'

Back

How do you create a dictionary in Python with keys k1 and k2 and values v1 and v2?

Front

{k1: v1, k2: v2}

Back

How you convert the integer 55 into a string?

Front

str(55)

Back

What is the Python relational operator for value inequality?

Front

!=

Back

How does Python define object equivalence?

Front

Two objects are equivalent if one could be used in place of another

Back

How do you create a floating point representation of infinity?

Front

float("inf")

Back

How do you represent else/if structures in Python?

Front

if cond1 case1 elif cond2 case2 else: case3

Back

How do you turn a string of numbers numstr into an integer?

Front

int(numstr)

Back

Which are immutable, lists or strings?

Front

Strings are immutable. Lists are mutable.

Back

How do you decode a byte object data using UTF-8

Front

data.decode("utf-8")

Back

How do you take the factorial of n?

Front

math.factorial(n)

Back

How do you import factorial as a function with 'fac' as an alias?

Front

from math import factorial as fac

Back

How do you encode a string norsk into a byte object data in UTF-8?

Front

data = norsk.encode("utf-8")

Back

What is the result of bool(0)?

Front

False

Back

Are Python dictionaries ordered?

Front

No.

Back

How do you exit the REPL on MacOSX?

Front

Ctrl-D

Back