Variables/user input/Conditionals/Relational
loops/random numbers/functions
Object Oriented Programming
Arrays/Machine Learning
100

In Python, a variable must be declared/created  before it is assigned a value:

True  or False?

False

100

 What is the difference between a for loop and a while loop?




For loop->runs for a certain amount of time

While loop -> can run for an uncertain amount of time

100

What is a class?

A class is a blueprint from which different objects are created.

100

What is an array?

An array is a collection of values or items

200

Which of the following statements assigns the value 100 to the variable x in Python:

 X = 100

 X :=100

 X << 100

 X == 100

x = 100

200

How would you call a function?

Lets just say I create a function:

def friend():

  #put some code in this and I am printing it to output

Now what I do to call it?

1. Come outside the function

2. type the function name like this friend()

def friend():

  #some code

friend()

200
What do programmers write to give their objects characteristics/attributes?

Constructor

200

What is the difference between a numpy array and an array?

numpy -> multidimensional

array -> 1 dimensional

300

What are the three variable types we covered in class?

    String, Integer, Boolean

    Char, int, bool

    Str, int, boolean

String, Integer, Boolean

300

isAlive = False

    While not isAlive:

        print(“Hi)

   Why won’t this while loop ever stop?



This is because we never made a condition to make isAlive True

300

class NBA:

    def __init__(self, name, ball):
        self.name = name

       self.ball = ball

    def game(self):
        print("Let's start the game!")

    def make_noise(self):
        print("DEFENSE")

basketball_game = NBA("Warriors", "basketball")


How can I access the name of the basketball's team?

300

How can I add 5 to all the values in a 1 Dimensional array?

1. Create empty list/array to store the sums

2. Use for loop that stops when it reaches the end of the array and appends array[i] + 5 every time the for loop execute like :

for i in range(len(arr)):

 num2.append(arr + 5)


400

Number_of_doughnuts = 4

    If number_of_doghnuts > 4:

        Number_of_doughnuts -= 3

    Else:

        Number_of_doughnuts +=9

What would this print if I typed print(Number_of_doughnuts)

13

400

How would you call a function?

Lets just say I create a function:

def friend():

     value = 5

     return value

Now what I do to call it?

How about if there was an argument like:

   

def friend(number):

     value = number

     return value


1. Outside the function initialize the function's name to a variable:

function = friend()

print(function)

2. function = friend(any value like 5)

   print(function)


400

class NBA:

    def __init__(self, teamName, ball):
        self.name = teamName

       self.ball = ball

    def game(self):
        print("Let's start the game!")

    def make_noise(self):
        print("DEFENSE")

basketball_game = NBA("Warriors", "basketball")

class Stephen_Curry(NBA):

   def three_pointer():

   print("Stephen curry shoots the 3 pointer!")

How can I make Stephen curry play a basketball game , I want to let stephen curry do the game function from above?

create Stephen curry object like :

player = Stephen_Curry("Warriors", "basketball")

player.game()

400

Machine learning is used to predict or conclude?

predict

500

number = input("Enter a number")

if number == 14:

   print("hi")

else:

   print("no")

What would be printed out if I ran this program?

It would give me an error because I didn't convert number to an integer

500

 Random = random.randint(0,3)

    

That is all I have written. When I run this code what should I get?


An error because I didn't import random

500

I want to create a car object that has an accelerator, brake attribute and a move function.

Take one minute to write this real quick

class car:

  def __init__(self, accelerator, brake):

     self.accelerator = accelerator

     self.brake = brake

def move(self):

   print("car is moving")

Car = car("accelator", "brake")

500
In machine learning, programmers split their dataset into two parts: one for running the model and another for seeing how the model is performing?

What are the names of these two splits?

Train and test

M
e
n
u