Data Types
Print
Control Structures/Loops
Lists
Functions
100

Name 3 data types in Python

Nombra 3 tipos de data en Python

what is:

1. Integer (e.g. 4)

2. Float (e.g. 4.0)

3. String (e.g. "hello")

4. Boolean

100

The OUTPUT of:

cookies = 10

for i in range (5):

     cookies -=1

     print ('nom nom COOKIE')

print ("I have", cookies+1, "cookies left")

OUTPUT:

nom nom COOKIE

nom nom COOKIE

nom nom COOKIE

nom nom COOKIE

nom nom COOKIE

I have 6 cookies left

100

"Else If" in python 

What is "elif"?

100

The output of:

phrase = "Is the word here"

print ('word' in phrase)

What is True?

100

The keyword we need to make a function.

What is "def"?

200

How do I turn a user input into an integer? Do I have to? What happens if the user inputs a letter? 

CODE:

user_input = input("Enter a number: ")


What is:

int(user_input)

Yes, if you want to use math operations.

There will be an error since you can't turn a letter into a number. 

200

The Output of:

dogs = 10

cats = 5

print ("There are %d dogs and %d cats." %(cats,dogs))

what is:

There are 5 dogs and 10 cats. 

200

The difference between:

word = "hello" 

for i in range (len(word)):

    print(word[i])

for c in word:

    print(c)

What is:

One uses indexes to extract character and the other directly works on the element/character

200

The output of:

number = []

number.append(1)

number.append(3)

number.append ([5,8])

print (number)

number.extend([10,14])

print (number)

What is:

[1,3,[5,8]]

[1,3,[5,8], 10,14]

With a list, append adds whatever is in the parenthesis to the back of the list (the entire list in parenthesis as one element). Extend extracts each element within the list and adds it to the back of the list

200

The difference between local and global variables.

Local: defined and restricted to the inside of the function

Global: Can be used anywhere in the file. Can be updated/changed anywhere.

300

The output of:

oranges = 10

apples = 15

print ("I have " + oranges + " oranges and " + apples + " apples.")


What is ERROR?


Remember, you cannot concatenate integers and strings UNLESS you convert the integer to a string using ____ . 
300

The output of:

user_input = input("Enter a number:")

print (user_input * 10)

1. Input: 10

2. Input: a

What is:

1.10101010101010101010

2. aaaaaaaaaa

300

The output when uinput = "y" and uinput = "N"

CODE:

uinput = input("Do you like the weather? ")

if (uinput == 'y'): 

    print("I don't") 

elif (uinput == 'n'):

    print("cool me neither")

else: 

   print ("what do you mean")

What is:

I don't

What do you mean

300

word = "banana" 

How to print out ALL the indexes where 'n' is

Use a list and a for i loop

300

What's going to happen?

def hi():

    print ("Hey there!")

def hello(word):

    return ("Hello " + word)

name = "georgia"

hi()

hello(name)

What is: 

Hey there!

400

The output of: 

print (int((float(5.0) + int('2'))) * "hi ")

What is:

hi hi hi hi hi hi hi

400

fruits = ["apples","peaches", "bananas","oranges"]

How do I print out this list such that the output is: 

apples

bananas

Show Solution. But you could use indexing w/ modulo to get and print even indices or splicing.

400

The output of:

count = 0

while (count < 10):

    print ("And I oop-")

    count -=1

What is: 

Infinity. This will run on forever and forever and forever. And I oop-

400

Output of: 

list = ['b','n','n']

index = 1

for c in range (len(list)):

    list.insert(index,'a')

    index +=2

print (list)

What is ['b', 'a', 'n', 'a', 'n', 'a']

400

What is "heya?

def ooga_booga(thing):

    return thing[::2]

random_stuff = ['go', 'bananas', 'dab','potato','oop','woah']

heya = ooga_booga(random_stuff)

print (heya)

what is ['go','dab','oop']

500

thing1 = True

thing2 = False

print (thing1 & (thing2| (thing2 & thing1)| (not thing2)))

Hint: & --> and, | --> or

What is True?

500

word = "cookie"

How do I get this output? USING A LOOP

Hint: use indexes :) 

e

i

k

o

o

c

Show solution

500

temp = 65

The Output of: 

if (temp < 65):

    print ("It's cold!")

elif (temp > 65 and temp < 80):

    print ("It's alright")

elif (temp >= 80 and temp <= 95):

    print ("It's HOT")

else:

    print ("It's SCORCHING HOT")

what is:

It's SCORCHING HOT!

500

The output of: 

nums = [1,19,6,10,-4,12,4,18,20,17,-2]

total = 0

for i in range (len(nums)):

    if (i % 2 == 0):

        total += nums[i]

print (total)

What is 25?

500

Show code

What is 6?

M
e
n
u