Section 1

Preview this deck

print('
' * 5)

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

2

All-time users

3

Favorites

0

Last updated

1 year ago

Date created

Mar 1, 2020

Cards (50)

Section 1

(50 cards)

print('
' * 5)

Front

print 5 new lines

Back

maps

Front

another term for the data type 'dictionary'

Back

class Dog(Animal):

Front

how do you create a class 'Dog' that inherits from the 'Animal' class

Back

name = sys.stdin.readline()

Front

how do you get the character typed by the user at the command line and assign it to a variable named 'name'

Back

__init(self)__

Front

what is the name of the class constructor

Back

random_num = random.randrange(0,100)

Front

how do you create a random number from 0 to 99 and assign it to a variable named 'random_num'

Back

for x in range(0, 10): print(x, ' ', end="") print(10-x, ' ', end="")

Front

using the 'for' loop, display '0 10 1 9 2 8 3 7 4 6 5 5 6 4 7 3 8 2 9 1 '

Back

grocery_list.append('Onions')

Front

how do you add 'Onions' at the end of the list named 'grocery_list'

Back

name = "Derek"

Front

Store "Derek" to a variable named 'name'

Back

%c

Front

print character formatting placeholder

Back

polymorphism

Front

allows us to refer to objects as their superclass and the correct functions are called automatically

Back

del grocery_list[4]

Front

how do you delete a specific item, say the 5th item, in a list named 'grocery_list'

Back

#

Front

Tag for a single line comment

Back

%s

Front

print string formatting placeholder

Back

02468

Front

what is the output of the following code script: i = 0; while(i <= 20): if(i%2 == 0): print(i, end="") elif(i == 9): break else: i += 1 continue i += 1 # This is equivalent to i = i + 1

Back

for x in range(0, 10): print(x, ' ', end="")

Front

using the 'for' loop, display '0 1 2 3 4 5 6 7 8 9 '

Back

dictionary

Front

a data type that has a unique key for each value; similar to list but you cannot join them together

Back

quote_list = long_string.split(" ")

Front

how do you explode the string named 'long_string' into a list named 'quote_list' at the space delimiter " "

Back

NumPy

Front

a scientific computing python package

Back

pip

Front

manages software packages for python

Back

def

Front

keyword to define a function

Back

print(grocery_list[1:3])

Front

how do you print elements '1' to '3' of the list 'grocery_list'

Back

print('First Item', grocery_list[0])

Front

how do you print "First Item" and appended to that is the first item in the list 'grocery_list'

Back

if (age >= 1) and (age <= 18): print("birthday") elif (age == 21) or (age >= 65): print("birthday") elif not(age == 30): print("no birthday") else: print("birthday party")

Front

implement the following logic without space preceding ":" symbol: age between 1 to 18 (inclusive) display "birthday" age is 21 or more than 65 (inclusive) display "birthday" age is not 30 display "no birthday" otherwise, display "birthday party"

Back

test_file.close()

Front

how do you close an open file handle named 'test_file'

Back

+

Front

operator to concatenate strings

Back

tuple

Front

unlike the list, you cannot change this data type after it is created

Back

grocery_list[0] = "Green Juice"

Front

how do you change the value of the first item in the list 'grocery_list' to "Green Juice"

Back

if age >= 21 : print('tractor trailer') elif age >= 16 : print('car') else : print("not old enough")

Front

implement the following logic with space preceding the ":" symbol: age >= 21 display "tractor trailer" age >= 16 display "car" age < 16 display "not old enough"

Back

random_num = random.randrange(0,100) while(random_num != 15): print(random_num) random_num = random.randrange(0,100)

Front

keep displaying a random number between 0 and 99 until a number 15 is randomly found

Back

class Animal:

Front

how do you declare a class named 'Animal'

Back

-3

Front

1+2-3*2

Back

grocery_list.remove('Pickle')

Front

how do you delete the item 'Pickle' from the list named 'grocery_list'

Back

%d

Front

print integer formatting placeholder

Back

+ - / % * //

Front

7 arithmetic operations

Back

and or not

Front

logical operators

Back

print(max(to_do_list2))

Front

how do you print the largest item, i.e., whatever comes last alphabetically, in the list named 'to_do_list2'

Back

grocery_list.reverse()

Front

how do you sort the items in a list named 'grocery_list' in descending order

Back

print(to_do_list[1][1])

Front

how do you display the 2nd item in the 2nd list of a list named to_do_list

Back

== != > >= < <=

Front

6 conditionals

Back

grocery_list = ['Juice', 'Tomatoes', 'Potatoes', 'Bananas']

Front

example on how to declare a list 'grocery_list' to contain 'Juice', 'Tomatoes', 'Potatoes', 'Bananas'

Back

while

Front

loop structure to use when you have no idea how many times you need to loop

Back

equally indented space

Front

what is used to group blocks of code in a python

Back

if else elif

Front

conditional that performs different actions based on different conditions

Back

function

Front

used to write more readable code

Back

'''

Front

Tag for a multiline comment

Back

grocery_list.sort()

Front

how do you sort the items in a list named 'grocery_list' alphabetically in ascending order

Back

cat = Animal('Whiskers', 33, 10, 'Meow')

Front

how do you get an instance of a class named 'Animal' whose constructor require the parameters: name, height, weight, sound

Back

__name = None

Front

how do you initialize a local variable in a class to nothing

Back

//

Front

integer division operator

Back